1
0
Fork 0

Added throwError warning handler

closure/master
Mike Gerwitz 2011-06-29 21:34:33 -04:00
parent 90aaaeb3a3
commit bdd7df2011
2 changed files with 38 additions and 0 deletions

View File

@ -91,5 +91,21 @@ exports.handlers = {
console && ( dest = console.warn || console.log ) && console && ( dest = console.warn || console.log ) &&
dest( warning.message ); dest( warning.message );
}, },
/**
* Throws the error associated with the warning
*
* This handler is useful for development and will ensure that problems are
* brought to the attention of the developer.
*
* @param {Warning} warning to log
*
* @return {undefined}
*/
throwError: function( warning )
{
throw warning.getError();
},
}; };

View File

@ -116,3 +116,25 @@ var common = require( './common' ),
console = console_; console = console_;
} )(); } )();
/**
* The throwError warning handler should throw the wrapped error as an exception
*/
( function testThrowErrorWarningHandlerThrowsWrappedError()
{
try
{
warn.handlers.throwError( warning );
}
catch ( e )
{
assert.deepEqual( e, warning.getError(),
"Wrapped exception should be thrown"
);
return;
}
assert.fail( "Wrapped exception should be thrown" );
} )();