diff --git a/spec/workspace-view-spec.coffee b/spec/workspace-view-spec.coffee index 69e9e2d7e..448284545 100644 --- a/spec/workspace-view-spec.coffee +++ b/spec/workspace-view-spec.coffee @@ -319,7 +319,15 @@ describe "WorkspaceView", -> atom.notifications.onDidAddNotification addedSpy = jasmine.createSpy() atom.workspace.saveActivePaneItem() + expect(addedSpy).toHaveBeenCalled() + expect(addedSpy.mostRecentCall.args[0].getType()).toBe 'warning' + 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'") + + atom.notifications.onDidAddNotification addedSpy = jasmine.createSpy() + atom.workspace.saveActivePaneItem() expect(addedSpy).toHaveBeenCalled() expect(addedSpy.mostRecentCall.args[0].getType()).toBe 'warning' diff --git a/src/workspace.coffee b/src/workspace.coffee index 03f5732cb..98630f7c2 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -571,9 +571,11 @@ 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 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.") + atom.notifications.addWarning("Unable to save file: A directory in the path '#{fileName}' could not be written to") else throw error