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