Added throwError warning handler
parent
90aaaeb3a3
commit
bdd7df2011
16
lib/warn.js
16
lib/warn.js
|
@ -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();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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" );
|
||||||
|
} )();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue