Handle is a directory error

Closes #4616
This commit is contained in:
Ben Ogle
2014-12-15 17:08:46 -08:00
parent fad93b8d7e
commit a42505b6ae
2 changed files with 35 additions and 2 deletions

View File

@@ -555,7 +555,7 @@ class Workspace extends Model
# {::saveActivePaneItemAs} # will be called instead. This method does nothing
# if the active item does not implement a `.save` method.
saveActivePaneItem: ->
@getActivePane().saveActiveItem()
@saveActivePaneItemAndReportErrors('saveActiveItem')
# Prompt the user for a path and save the active pane item to it.
#
@@ -563,7 +563,16 @@ class Workspace extends Model
# `.saveAs` on the item with the selected path. This method does nothing if
# the active item does not implement a `.saveAs` method.
saveActivePaneItemAs: ->
@getActivePane().saveActiveItemAs()
@saveActivePaneItemAndReportErrors('saveActiveItemAs')
saveActivePaneItemAndReportErrors: (method) ->
try
@getActivePane()[method]()
catch error
if error.message.endsWith('is a directory')
atom.notifications.addWarning("Unable to save file: #{error.message}")
else
throw error
# Destroy (close) the active pane item.
#