Handle errors when attempting to add a file from the TreeView

This commit is contained in:
Nathan Sobo
2012-05-08 15:02:07 -06:00
parent a59c96d3a9
commit d181cdedbd
2 changed files with 60 additions and 26 deletions

View File

@@ -188,11 +188,19 @@ class TreeView extends View
onConfirm: (relativePath) =>
endsWithDirectorySeperator = /\/$/.test(relativePath)
path = @rootView.project.resolve(relativePath)
if endsWithDirectorySeperator
fs.makeDirectory(path)
else
fs.write(path, "")
@rootView.open(path)
try
if endsWithDirectorySeperator
fs.makeDirectory(path)
else
if fs.exists(path)
dialog.showError("Error: A file already exists at path '#{path}'. Try a different path:")
false
else
fs.write(path, "")
@rootView.open(path)
catch e
dialog.showError("Error: " + e.message + " Try a different path:")
return false
@rootView.append(dialog)