diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-28 11:42:54 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-28 11:42:54 -0700 |
commit | 1844811464c9cfb71bc315e24c61707414db88e6 (patch) | |
tree | a817c32f3006005bd468cfbf6c22e7c558d4eba4 /src/library_fs.js | |
parent | 84272ebefa19a65ccb55a853a81e0a87adf9f213 (diff) |
reuse some FS errors in places where overhead is high and stack importance is low
Diffstat (limited to 'src/library_fs.js')
-rw-r--r-- | src/library_fs.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/library_fs.js b/src/library_fs.js index bd1522a8..90f5d3b0 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -28,6 +28,7 @@ mergeInto(LibraryManager.library, { ignorePermissions: true, ErrnoError: null, // set during init + genericErrors: {}, handleFSError: function(e) { if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace(); @@ -1079,6 +1080,11 @@ mergeInto(LibraryManager.library, { }; FS.ErrnoError.prototype = new Error(); FS.ErrnoError.prototype.constructor = FS.ErrnoError; + // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info) + [ERRNO_CODES.ENOENT].forEach(function(code) { + FS.genericErrors[code] = new FS.ErrnoError(code); + FS.genericErrors[code].stack = '<generic error, no stack>'; + }); }, staticInit: function() { FS.ensureErrnoError(); |