From 7d88f9ea666e086c5d1d9626c76ba656e898be80 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 8 Jul 2015 13:08:23 -0700 Subject: [PATCH 01/10] Use item path when error has no path --- src/pane.coffee | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/pane.coffee b/src/pane.coffee index c19eb26d4..55209241b 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -491,7 +491,7 @@ class Pane extends Model try item.save?() catch error - @handleSaveError(error) + @handleSaveError(error, item) nextAction?() else @saveItemAs(item, nextAction) @@ -512,7 +512,7 @@ class Pane extends Model try item.saveAs(newItemPath) catch error - @handleSaveError(error) + @handleSaveError(error, item) nextAction?() # Public: Save all items. @@ -676,19 +676,24 @@ class Pane extends Model return false unless @promptToSaveItem(item) true - handleSaveError: (error) -> + handleSaveError: (error, paneItem) -> + itemPath = error.path ? paneItem.getPath?() + addWarningWithPath = (message, options) -> + message = "#{message} '#{itemPath}'" if itemPath + atom.notifications.addWarning(message, options) + if error.code is 'EISDIR' or error.message?.endsWith?('is a directory') atom.notifications.addWarning("Unable to save file: #{error.message}") - else if error.code is 'EACCES' and error.path? - atom.notifications.addWarning("Unable to save file: Permission denied '#{error.path}'") - else if error.code in ['EPERM', 'EBUSY', 'UNKNOWN', 'EEXIST'] and error.path? - atom.notifications.addWarning("Unable to save file '#{error.path}'", detail: error.message) - else if error.code is 'EROFS' and error.path? - atom.notifications.addWarning("Unable to save file: Read-only file system '#{error.path}'") - else if error.code is 'ENOSPC' and error.path? - atom.notifications.addWarning("Unable to save file: No space left on device '#{error.path}'") - else if error.code is 'ENXIO' and error.path? - atom.notifications.addWarning("Unable to save file: No such device or address '#{error.path}'") + else if error.code is 'EACCES' + addWarningWithPath('Unable to save file: Permission denied') + else if error.code in ['EPERM', 'EBUSY', 'UNKNOWN', 'EEXIST'] + 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 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") From 3e744b0714b740f55aa45b4f834b1cd00b42f3f7 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 8 Jul 2015 13:11:27 -0700 Subject: [PATCH 02/10] Add custom notification for ENOTSUP --- src/pane.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pane.coffee b/src/pane.coffee index 55209241b..a66eacbce 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -694,6 +694,8 @@ class Pane extends Model 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 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") From c3e73bdd263c04ca60fb26df0044e348fc70fd6c Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 8 Jul 2015 13:15:45 -0700 Subject: [PATCH 03/10] Add custom notification for EIO --- src/pane.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pane.coffee b/src/pane.coffee index a66eacbce..1f85c3b4e 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -696,6 +696,8 @@ class Pane extends Model 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 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") From 485f4dc3a3871e6a9dd61e2c855393d3b322fd28 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 8 Jul 2015 14:05:37 -0700 Subject: [PATCH 04/10] Add custom notification for EINTR --- src/pane.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pane.coffee b/src/pane.coffee index 1f85c3b4e..66edf70b7 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -698,6 +698,8 @@ class Pane extends Model 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 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") From 8c9ecbaf034dac494662f40f98ee3a2a1d1455f2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 8 Jul 2015 14:06:56 -0700 Subject: [PATCH 05/10] Add custom notification for ESPIPE --- src/pane.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pane.coffee b/src/pane.coffee index 66edf70b7..fc861a95f 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -700,6 +700,8 @@ class Pane extends Model 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 'ESPIPE' + addWarningWithPath('Unable to save file: Invalid seek') 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") From 770dc9821e3d6547c62e54dd66134ea83b349299 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 8 Jul 2015 14:08:16 -0700 Subject: [PATCH 06/10] paneItem -> item for consistency --- src/pane.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pane.coffee b/src/pane.coffee index fc861a95f..384b53b57 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -676,8 +676,8 @@ class Pane extends Model return false unless @promptToSaveItem(item) true - handleSaveError: (error, paneItem) -> - itemPath = error.path ? paneItem.getPath?() + handleSaveError: (error, item) -> + itemPath = error.path ? item.getPath?() addWarningWithPath = (message, options) -> message = "#{message} '#{itemPath}'" if itemPath atom.notifications.addWarning(message, options) From de4cf38dcceb5010d4dc9dbfd0550b1d02adab9f Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 8 Jul 2015 14:41:07 -0700 Subject: [PATCH 07/10] Handle ENXIO open errors --- src/workspace.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workspace.coffee b/src/workspace.coffee index 564152df6..c6f9a9066 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -442,7 +442,7 @@ class Workspace extends Model when 'EACCES' atom.notifications.addWarning("Permission denied '#{error.path}'") return Q() - when 'EPERM', 'EBUSY' + when 'EPERM', 'EBUSY', 'ENXIO' atom.notifications.addWarning("Unable to open '#{error.path}'", detail: error.message) return Q() else From 955749b32094df2798309cf7763c100d8f89218e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 8 Jul 2015 14:45:57 -0700 Subject: [PATCH 08/10] Handle EIO open errors --- src/workspace.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workspace.coffee b/src/workspace.coffee index c6f9a9066..ab3a201fd 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -442,7 +442,7 @@ class Workspace extends Model when 'EACCES' atom.notifications.addWarning("Permission denied '#{error.path}'") return Q() - when 'EPERM', 'EBUSY', 'ENXIO' + when 'EPERM', 'EBUSY', 'ENXIO', 'EIO' atom.notifications.addWarning("Unable to open '#{error.path}'", detail: error.message) return Q() else From 27a94b4d706a463fea4b3438299a159cb6059e64 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 8 Jul 2015 14:46:56 -0700 Subject: [PATCH 09/10] Handle ENOTCONN open errors --- src/workspace.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workspace.coffee b/src/workspace.coffee index ab3a201fd..83dbc6280 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -442,7 +442,7 @@ class Workspace extends Model when 'EACCES' atom.notifications.addWarning("Permission denied '#{error.path}'") return Q() - when 'EPERM', 'EBUSY', 'ENXIO', 'EIO' + when 'EPERM', 'EBUSY', 'ENXIO', 'EIO', 'ENOTCONN' atom.notifications.addWarning("Unable to open '#{error.path}'", detail: error.message) return Q() else From 22f7379f3256ea7b1ed31547d4d091c5c501dd6e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 8 Jul 2015 14:54:01 -0700 Subject: [PATCH 10/10] Handle UNKNOWN open errors --- src/workspace.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workspace.coffee b/src/workspace.coffee index 83dbc6280..28e6efc73 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -442,7 +442,7 @@ class Workspace extends Model when 'EACCES' atom.notifications.addWarning("Permission denied '#{error.path}'") return Q() - when 'EPERM', 'EBUSY', 'ENXIO', 'EIO', 'ENOTCONN' + when 'EPERM', 'EBUSY', 'ENXIO', 'EIO', 'ENOTCONN', 'UNKNOWN' atom.notifications.addWarning("Unable to open '#{error.path}'", detail: error.message) return Q() else