mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
Use the error.code and path in the error
This commit is contained in:
parent
2f3ce50875
commit
d5e04e883e
@ -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()
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user