Merge pull request #10310 from atom/ku-handle-more-fs-errors

Handle EAGAIN and ETIMEDOUT errors on open/save
This commit is contained in:
Katrina Uychaco
2016-01-07 16:49:14 -08:00
2 changed files with 18 additions and 20 deletions

View File

@@ -721,30 +721,28 @@ class Pane extends Model
message = "#{message} '#{itemPath}'" if itemPath
@notificationManager.addWarning(message, options)
if error.code is 'EISDIR' or error.message?.endsWith?('is a directory')
customMessage = @getMessageForErrorCode(error.code)
if customMessage?
addWarningWithPath("Unable to save file: #{customMessage}")
else if error.code is 'EISDIR' or error.message?.endsWith?('is a directory')
@notificationManager.addWarning("Unable to save file: #{error.message}")
else if error.code is 'EACCES'
addWarningWithPath('Unable to save file: Permission denied')
else if error.code in ['EPERM', 'EBUSY', 'UNKNOWN', 'EEXIST', 'ELOOP', 'EAGAIN']
addWarningWithPath('Unable to save file', detail: error.message)
else if error.code is 'EROFS'
addWarningWithPath('Unable to save file: Read-only file system')
else if error.code is 'ENOSPC'
addWarningWithPath('Unable to save file: No space left on device')
else if error.code is 'ENXIO'
addWarningWithPath('Unable to save file: No such device or address')
else if error.code is 'ENOTSUP'
addWarningWithPath('Unable to save file: Operation not supported on socket')
else if error.code is 'EIO'
addWarningWithPath('Unable to save file: I/O error writing file')
else if error.code is 'EINTR'
addWarningWithPath('Unable to save file: Interrupted system call')
else if error.code is 'ECONNRESET'
addWarningWithPath('Unable to save file: Connection reset')
else if error.code is 'ESPIPE'
addWarningWithPath('Unable to save file: Invalid seek')
else if errorMatch = /ENOTDIR, not a directory '([^']+)'/.exec(error.message)
fileName = errorMatch[1]
@notificationManager.addWarning("Unable to save file: A directory in the path '#{fileName}' could not be written to")
else
throw error
getMessageForErrorCode: (errorCode) ->
switch errorCode
when 'EACCES' then 'Permission denied'
when 'ECONNRESET' then 'Connection reset'
when 'EINTR' then 'Interrupted system call'
when 'EIO' then 'I/O error writing file'
when 'ENOSPC' then 'No space left on device'
when 'ENOTSUP' then 'Operation not supported on socket'
when 'ENXIO' then 'No such device or address'
when 'EROFS' then 'Read-only file system'
when 'ESPIPE' then 'Invalid seek'
when 'ETIMEDOUT' then 'Connection timed out'

View File

@@ -475,7 +475,7 @@ class Workspace extends Model
when 'EACCES'
@notificationManager.addWarning("Permission denied '#{error.path}'")
return Promise.resolve()
when 'EPERM', 'EBUSY', 'ENXIO', 'EIO', 'ENOTCONN', 'UNKNOWN', 'ECONNRESET', 'EINVAL', 'EMFILE', 'ENOTDIR'
when 'EPERM', 'EBUSY', 'ENXIO', 'EIO', 'ENOTCONN', 'UNKNOWN', 'ECONNRESET', 'EINVAL', 'EMFILE', 'ENOTDIR', 'EAGAIN'
@notificationManager.addWarning("Unable to open '#{error.path ? uri}'", detail: error.message)
return Promise.resolve()
else