@duncte123/obs-websocket-js
Version:
OBS Websocket API in Javascript, consumes @Palakis/obs-websocket
25 lines (24 loc) • 931 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Disambiguates an "error" and formats it nicely for `debug` output.
* Particularly useful when dealing with error response objects from obs-websocket,
* which are not actual Error-type errors, but simply Objects.
*
* @param {Object} debug A `debug` instance.
* @param {String} prefix A string to print in front of the formatted error.
* @param {Object|Error} error An error of ambiguous type that you wish to log to `debug`. Can be an Error, Object, or String.
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function default_1(debug, prefix, error) {
if (error && error.stack) {
debug(`${prefix}\n %O`, error.stack);
}
else if (typeof error === 'object') {
debug(`${prefix} %o`, error);
}
else {
debug(`${prefix} %s`, error);
}
}
exports.default = default_1;