Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
set (value) {
if (isError(value)) {
return value
}
return new Error(value)
}
}
function parseConstructorArguments(args)
{
var argv, options, sprintf_args, shortmessage, k;
mod_assertplus.object(args, 'args');
mod_assertplus.bool(args.strict, 'args.strict');
mod_assertplus.array(args.argv, 'args.argv');
argv = args.argv;
/*
* First, figure out which form of invocation we've been given.
*/
if (argv.length === 0) {
options = {};
sprintf_args = [];
} else if (mod_isError(argv[0])) {
options = { 'cause': argv[0] };
sprintf_args = argv.slice(1);
} else if (typeof (argv[0]) === 'object') {
options = {};
for (k in argv[0]) {
options[k] = argv[0][k];
}
sprintf_args = argv.slice(1);
} else {
mod_assertplus.string(argv[0],
'first argument to VError, SError, or WError ' +
'constructor must be a string, object, or Error');
options = {};
sprintf_args = argv;
}
function parseConstructorArguments(args)
{
var argv, options, sprintf_args, shortmessage, k;
mod_assertplus.object(args, 'args');
mod_assertplus.bool(args.strict, 'args.strict');
mod_assertplus.array(args.argv, 'args.argv');
argv = args.argv;
/*
* First, figure out which form of invocation we've been given.
*/
if (argv.length === 0) {
options = {};
sprintf_args = [];
} else if (mod_isError(argv[0])) {
options = { 'cause': argv[0] };
sprintf_args = argv.slice(1);
} else if (typeof (argv[0]) === 'object') {
options = {};
for (k in argv[0]) {
options[k] = argv[0][k];
}
sprintf_args = argv.slice(1);
} else {
mod_assertplus.string(argv[0],
'first argument to VError, SError, or WError ' +
'constructor must be a string, object, or Error');
options = {};
sprintf_args = argv;
}
VError.findCauseByName = function (err, name)
{
var cause;
mod_assertplus.ok(mod_isError(err), 'err must be an Error');
mod_assertplus.string(name, 'name');
mod_assertplus.ok(name.length > 0, 'name cannot be empty');
for (cause = err; cause !== null; cause = VError.cause(cause)) {
mod_assertplus.ok(mod_isError(cause));
if (cause.name == name) {
return (cause);
}
}
return (null);
};
errors.forEach(function (e) {
mod_assertplus.ok(mod_isError(e));
});
VError.findCauseByName = function (err, name)
{
var cause;
mod_assertplus.ok(mod_isError(err), 'err must be an Error');
mod_assertplus.string(name, 'name');
mod_assertplus.ok(name.length > 0, 'name cannot be empty');
for (cause = err; cause !== null; cause = VError.cause(cause)) {
mod_assertplus.ok(mod_isError(cause));
if (cause.name == name) {
return (cause);
}
}
return (null);
};
WError.prototype.cause = function we_cause(c)
{
if (mod_isError(c))
this.jse_cause = c;
return (this.jse_cause);
};
VError.findCauseByName = function (err, name)
{
var cause;
mod_assertplus.ok(mod_isError(err), 'err must be an Error');
mod_assertplus.string(name, 'name');
mod_assertplus.ok(name.length > 0, 'name cannot be empty');
for (cause = err; cause !== null; cause = VError.cause(cause)) {
mod_assertplus.ok(mod_isError(cause));
if (cause.name == name) {
return (cause);
}
}
return (null);
};
errors.forEach(function (e) {
mod_assertplus.ok(mod_isError(e));
});
WError.prototype.cause = function we_cause(c)
{
if (mod_isError(c))
this.jse_cause = c;
return (this.jse_cause);
};