Created
August 16, 2011 03:27
Revisions
-
tshinnic created this gist
Aug 16, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,92 @@ //XXX Maybe someday there will be a nice way for user-land modules to // generate pseudo-errno errors? function errnoException(errno, syscall, message, path) { var e = new Error(); var msg = ''; if ( syscall !== undefined ) { msg += syscall + ' '; e.syscall = syscall; } if ( errno !== undefined ) { // Try to resolve errno to both a name and a value if ( typeof errno === 'string' && isOwn.call(constants, errno) ) { e.code = errno; e.errno = constants[errno]; msg += errno; } else { e.code = e.errno = errno; msg += errno.toString(); } } if ( message !== undefined ) { if ( msg !== '' ) { msg += ', '; } msg += message; } if ( path !== undefined ) { if ( msg !== '' ) { msg += ' '; } msg += '\'' + path + '\''; e.path = path; } e.message = msg; return e; } Saw real exception object true (instanceof Error) { stack: [Getter/Setter], arguments: undefined, type: undefined, message: 'ELOOP, Too many levels of symbolic links \'/home/Tom/study/javascript/node.js/play/test/tmp/testrpx/realpath-3a\'', errno: 40, code: 'ELOOP', path: '/home/Tom/study/javascript/node.js/play/test/tmp/testrpx/realpath-3a' } Saw fake exception object true (instanceof Error) { stack: [Getter/Setter], arguments: undefined, type: undefined, code: 'ELOOP', errno: 40, path: '/home/Tom/study/javascript/node.js/play/test/tmp/testrpx/realpath-3a', message: 'ELOOP, Too many levels of symbolic links \'/home/Tom/study/javascript/node.js/play/test/tmp/testrpx/realpath-3a\'' } Throwing the 'real' exception node.js:134 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: ELOOP, Too many levels of symbolic links '/home/Tom/study/javascript/node.js/play/test/tmp/testrpx/realpath-3a' at Object.statSync (fs.js:400:18) at realpathX (/home/Tom/study/javascript/node.js/play/pathroot.js:408:18) at test_cyclic_link Throwing the 'fake' exception node.js:134 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: ELOOP, Too many levels of symbolic links '/home/Tom/study/javascript/node.js/play/test/tmp/testrpx/realpath-3a' at errnoException (/home/Tom/study/javascript/node.js/play/pathroot.js:51:11) at realpathX (/home/Tom/study/javascript/node.js/play/pathroot.js:395:21) at test_cyclic_link_protection (/home/Tom/study/javascript/node.js/play/test/test_realpathx02.js:281:12) lt(' Saw real exception ', typeof ex, ex instanceof Error); lt(ex); var exx = errnoException('ELOOP', undefined, 'Too many levels of symbolic links', base); lt(' Saw fake exception ', typeof exx, exx instanceof Error); lt(exx); throw exx;