Use the error.code and path in the error

This commit is contained in:
Ben Ogle
2015-01-07 17:12:55 -08:00
parent 2f3ce50875
commit d5e04e883e
2 changed files with 6 additions and 3 deletions

View File

@@ -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")