assert() that won't expload when not in 'dev' mode
This commit is contained in:
parent
3bae109537
commit
6fa19f9ac3
|
@ -0,0 +1,18 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
// ENiGMA½
|
||||
const Config = require('./config.js').config;
|
||||
const Log = require('./logger.js').log;
|
||||
|
||||
// deps
|
||||
const assert = require('assert');
|
||||
|
||||
module.exports = function(condition, message) {
|
||||
if(Config.debug.assertsEnabled) {
|
||||
assert.apply(this, arguments);
|
||||
} else if(!(condition)) {
|
||||
const stack = new Error().stack;
|
||||
Log.error( { condition : condition, stack : stack }, message || 'Assertion failed' );
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue