diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-08-15 21:32:08 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-08-15 21:32:08 -0700 |
commit | a7b1ef9be07f040c751ea1f65aaf4e02989f4f89 (patch) | |
tree | a3344ed53daa56577fcdf686c635bac080eec9e9 | |
parent | 700d05119667a11111cdbf21c9d421a7e60fb248 (diff) | |
parent | 3b871e28f328c45835f75d29e790bfc808f2f002 (diff) |
Merge pull request #1511 from inolen/errnoerror
make FS.ErrnoError inherit from Error
-rw-r--r-- | src/library_fs.js | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/library_fs.js b/src/library_fs.js index 8ea6b06f..51341a3e 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -27,16 +27,21 @@ mergeInto(LibraryManager.library, { // to modify the filesystem freely before run() is called. ignorePermissions: true, - ErrnoError: function(errno) { - this.errno = errno; - for (var key in ERRNO_CODES) { - if (ERRNO_CODES[key] === errno) { - this.code = key; - break; + ErrnoError: (function() { + function ErrnoError(errno) { + this.errno = errno; + for (var key in ERRNO_CODES) { + if (ERRNO_CODES[key] === errno) { + this.code = key; + break; + } } - } - this.message = ERRNO_MESSAGES[errno] + ' : ' + new Error().stack; - }, + this.message = ERRNO_MESSAGES[errno]; + }; + ErrnoError.prototype = new Error(); + ErrnoError.prototype.constructor = ErrnoError; + return ErrnoError; + }()), handleFSError: function(e) { if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + new Error().stack; |