parent
bdd7df2011
commit
f405f072f2
19
lib/warn.js
19
lib/warn.js
|
@ -107,5 +107,24 @@ exports.handlers = {
|
|||
{
|
||||
throw warning.getError();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Ignores warnings
|
||||
*
|
||||
* This is useful in a production environment where (a) warnings will affect
|
||||
* the reputation of the software or (b) warnings may provide too much
|
||||
* insight into the software. If using this option, you should always
|
||||
* develop in a separate environment so that the system may bring warnings
|
||||
* to your attention.
|
||||
*
|
||||
* @param {Warning} warning to log
|
||||
*
|
||||
* @return {undefined}
|
||||
*/
|
||||
dismiss: function( warning )
|
||||
{
|
||||
// do nothing
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -138,3 +138,25 @@ var common = require( './common' ),
|
|||
assert.fail( "Wrapped exception should be thrown" );
|
||||
} )();
|
||||
|
||||
|
||||
/**
|
||||
* The 'dismiss' error handler is a pretty basic concept. Simply do nothing. We
|
||||
* don't want to log, we don't want to throw anything, we just want to pretend
|
||||
* nothing ever happened and move on our merry way. This is intended for use in
|
||||
* production environments where providing warnings may provide too much insight
|
||||
* into the software.
|
||||
*/
|
||||
( function testDismissWarningHandlerShouldDoNothing()
|
||||
{
|
||||
// destroy the console to ensure nothing is logged
|
||||
var console_ = console;
|
||||
console = undefined;
|
||||
|
||||
// don't catch anything, to ensure no errors occur and that no exceptions
|
||||
// are thrown
|
||||
warn.handlers.dismiss( warning );
|
||||
|
||||
// restore console
|
||||
console = console_;
|
||||
} )();
|
||||
|
||||
|
|
Loading…
Reference in New Issue