adobe/brackets — pull request #2318 by jbalsas (2012-12-09 20:21:46+00:00)
Title: NativeFileError for error callbacks in NativeFileSystem (#2057)

This is a possible fix for #2057. It introduces a new `NativeFileError` implementing `DOMError` to substitute the current `FileError` as the specs dictate.

__Important changes__
- There's no need anymore for the `FileError` polyfill
- `NativeFileSystem.FileError` is moved to its own module `NativeFileError`. I thougth it would make more sense, and avoids dependencies with `NativeFileSystem` when only wanting to check error name values.
- `_nativeToFileError` has been modified to just convert a brackets.fs error code to a NativeFileError error name. Hopefully this clears out any confusion in NativeFileSystem by making explicit all the error constructors in the same way.
- `DOMError` has a `name` attribute where `FileError` had `code`.

__Notes__
- There's no longer a dependency with the browser implementation of `FileError`, nor the need to use a polyfill for the in-browser branch.
- Errors that don't have a custom message are more descriptive when printed on dialog errors (i.e. instead of showing _error.4_ you now see something like _error.NOT_READABLE_ERR_)
- The attribute change between `DOMError` and `FileError` may break error handling in existing extensions. We could add a `code` attribute in our `NativeFileError` class to ensure backward compatibility. I've done a quick search though, and only three extensions seem to be using error.code right now.
- I've run all the unit tests and smoke tests and everything seems to be working fine so I hope I didn't miss anything, but this change affects several files, so it could be a good idea to split it into several pull requests if you don't feel it's safe enough.