Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Better errors #4906

Merged
merged 35 commits into from Jan 15, 2015
Merged

Better errors #4906

merged 35 commits into from Jan 15, 2015

Conversation

benogle
Copy link
Contributor

@benogle benogle commented Jan 8, 2015

TODO

  • Open access errors
  • Errors on read after file change event
  • unable to watch path errors for config, keymap, user scripts on startup
  • Make sure the bad-config errors arent crazy

@kevinsawicki
Copy link
Contributor

Love this 👍

@benogle
Copy link
Contributor Author

benogle commented Jan 8, 2015

There are so many places we throw sketch app-killing errors.

@@ -282,7 +287,9 @@ class Project extends Model
# Returns a promise that resolves to the {TextBuffer}.
buildBuffer: (absoluteFilePath) ->
if fs.getSizeSync(absoluteFilePath) >= 2 * 1048576 # 2MB
throw new Error("Atom can only handle files < 2MB for now.")
error = new Error("Atom can only handle files < 2MB for now.")
error.name = 'OversizeFileError'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about just using a custom code instead? To be consistent with other IO errors from node.

This could be be like error.code = 'ETOOLARGETOOPEN' or something.

item ?= atom.project.open(uri, options)
catch error
if error.code is 'EFILETOOLARGE'
atom.notifications.addWarning(error.message + " Large file support is being tracked at [atom/atom#307](https://github.com/atom/atom/issues/307).")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💄 "#{error.message} Large file support..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obv

@@ -832,25 +832,29 @@ class Config
@configFileHasErrors = false
catch error
@configFileHasErrors = true
@notifyFailure('Failed to load config.cson', error)
if error.location?
@notifyFailure('Failed to load config.cson', error.stack)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be config.json so you may want to use path.basename(@getUserConfigPath())

@benogle
Copy link
Contributor Author

benogle commented Jan 14, 2015

Ok, I think this is ready to go. @kevinsawicki another quick pass would be rad

@kevinsawicki
Copy link
Contributor

Just a heads up, you might want to rebase, doesn't look like this will merge cleanly currently.


KeymapManager::subscribeToFileReadFailure = ->
this.onDidFailToReadFile (error) ->
atom.notifications.addError('Failed to load keymap.cson', {detail: error.stack, dismissable: true})
this.onDidFailToReadFile (error) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ instead of this? I see it was using this before, but might be nice to change it now since it is being edited.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.