2016-08-26 21:29:49 -06:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
2018-06-22 21:26:46 -06:00
|
|
|
// ENiGMA½
|
2022-06-05 14:04:25 -06:00
|
|
|
const Config = require('./config.js').get;
|
|
|
|
const Log = require('./logger.js').log;
|
2016-08-26 21:29:49 -06:00
|
|
|
|
2018-06-22 21:26:46 -06:00
|
|
|
// deps
|
2022-06-05 14:04:25 -06:00
|
|
|
const assert = require('assert');
|
2016-08-26 21:29:49 -06:00
|
|
|
|
2022-06-05 14:04:25 -06:00
|
|
|
module.exports = function (condition, message) {
|
|
|
|
if (Config().debug.assertsEnabled) {
|
2018-06-21 23:15:04 -06:00
|
|
|
assert.apply(this, arguments);
|
2022-06-05 14:04:25 -06:00
|
|
|
} else if (!condition) {
|
2018-06-21 23:15:04 -06:00
|
|
|
const stack = new Error().stack;
|
2022-06-05 14:04:25 -06:00
|
|
|
Log.error({ condition: condition, stack: stack }, message || 'Assertion failed');
|
2018-06-21 23:15:04 -06:00
|
|
|
}
|
2016-08-26 21:29:49 -06:00
|
|
|
};
|