mirror of
https://github.com/atom/atom.git
synced 2026-02-09 22:24:59 -05:00
Merge pull request #10310 from atom/ku-handle-more-fs-errors
Handle EAGAIN and ETIMEDOUT errors on open/save
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user