1
0
Fork 0

Added 'dismiss' warning handler

- Phew. That was a hard one.
closure/master
Mike Gerwitz 2011-06-29 21:39:50 -04:00
parent bdd7df2011
commit f405f072f2
2 changed files with 41 additions and 0 deletions

View File

@ -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
},
};

View File

@ -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_;
} )();