diff --git a/spec/workspace-view-spec.coffee b/spec/workspace-view-spec.coffee index ade0dcc4d..e2065a661 100644 --- a/spec/workspace-view-spec.coffee +++ b/spec/workspace-view-spec.coffee @@ -318,7 +318,10 @@ describe "WorkspaceView", -> it "emits a warning notification when the user does not have permission", -> spyOn(Pane::, 'saveActiveItem').andCallFake -> - throw new Error("EACCES, permission denied '/Some/dir/and-a-file.js'") + error = new Error("EACCES, permission denied '/Some/dir/and-a-file.js'") + error.code = 'EACCES' + error.path = '/Some/dir/and-a-file.js' + throw error atom.notifications.onDidAddNotification addedSpy = jasmine.createSpy() atom.workspace.saveActivePaneItem() diff --git a/src/workspace.coffee b/src/workspace.coffee index 4efd1d6e6..3c11c7d27 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -624,8 +624,8 @@ class Workspace extends Model catch error if error.message.endsWith('is a directory') atom.notifications.addWarning("Unable to save file: #{error.message}") - else if error.message.startsWith('EACCES,') - atom.notifications.addWarning("Unable to save file: #{error.message.replace('EACCES, ', '')}") + else if error.code is 'EACCES' and error.path? + atom.notifications.addWarning("Unable to save file: Permission denied '#{error.path}'") else if errorMatch = /ENOTDIR, not a directory '([^']+)'/.exec(error.message) fileName = errorMatch[1] atom.notifications.addWarning("Unable to save file: A directory in the path '#{fileName}' could not be written to")