Last active
December 15, 2015 15:28
-
-
Save 19h/5281658 to your computer and use it in GitHub Desktop.
Custom /require/ with exception handler for V8 (Node).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try {delete e;e;}catch(e){v8=e.stack!=void 0}finally{v8=v8||0} | |
| var _$ = require; | |
| require = function(k) { | |
| try { | |
| return _$(k); | |
| } catch (e) { | |
| if (v8) { | |
| (_ = e.stack.split("\n"), __ = ""); | |
| for (var a in _) null != _[a].match(/\(([^)]+)\)/g) && (__ += Array(+a + 1).join(" ") + "=> " + _[a].match(/\(([^)]+)\)/g) + "\n"); | |
| console.log(_[0], "[" + k + "]\n", __), process.exit(); | |
| } else { | |
| console.trace("=== FATAL ERROR: \"" + k + "\" ==="), process.exit(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment