mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 12:47:13 +02:00
assert() that won't expload when not in 'dev' mode
This commit is contained in:
parent
3bae109537
commit
6fa19f9ac3
1 changed files with 18 additions and 0 deletions
18
core/enigma_assert.js
Normal file
18
core/enigma_assert.js
Normal file
|
@ -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…
Add table
Add a link
Reference in a new issue