errors: fix stack traces.
This commit is contained in:
parent
cedc54436a
commit
053561f2ba
@ -302,15 +302,15 @@ RPCBase.prototype.attach = function attach(rpc) {
|
||||
function RPCError(code, msg) {
|
||||
Error.call(this);
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, RPCError);
|
||||
|
||||
assert(typeof code === 'number');
|
||||
assert(typeof msg === 'string');
|
||||
|
||||
this.type = 'RPCError';
|
||||
this.message = msg;
|
||||
this.code = code;
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, RPCError);
|
||||
}
|
||||
|
||||
util.inherits(RPCError, Error);
|
||||
|
||||
@ -85,12 +85,12 @@ RPCClient.prototype.execute = async function execute(method, params) {
|
||||
function RPCError(msg, code) {
|
||||
Error.call(this);
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, RPCError);
|
||||
|
||||
this.type = 'RPCError';
|
||||
this.message = msg + '';
|
||||
this.code = code >>> 0;
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, RPCError);
|
||||
}
|
||||
|
||||
util.inherits(RPCError, Error);
|
||||
|
||||
@ -1803,9 +1803,6 @@ CoinSelector.prototype.selectHard = function selectHard() {
|
||||
function FundingError(msg, available, required) {
|
||||
Error.call(this);
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, FundingError);
|
||||
|
||||
this.type = 'FundingError';
|
||||
this.message = msg;
|
||||
this.availableFunds = -1;
|
||||
@ -1817,6 +1814,9 @@ function FundingError(msg, available, required) {
|
||||
this.availableFunds = available;
|
||||
this.requiredFunds = required;
|
||||
}
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, FundingError);
|
||||
}
|
||||
|
||||
util.inherits(FundingError, Error);
|
||||
|
||||
@ -38,9 +38,6 @@ const util = require('../utils/util');
|
||||
function VerifyError(msg, code, reason, score, malleated) {
|
||||
Error.call(this);
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, VerifyError);
|
||||
|
||||
assert(typeof code === 'string');
|
||||
assert(typeof reason === 'string');
|
||||
assert(score >= 0);
|
||||
@ -55,6 +52,9 @@ function VerifyError(msg, code, reason, score, malleated) {
|
||||
|
||||
this.message = `Verification failure: ${reason}`
|
||||
+ ` (code=${code} score=${score} hash=${msg.rhash()})`;
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, VerifyError);
|
||||
}
|
||||
|
||||
util.inherits(VerifyError, Error);
|
||||
|
||||
@ -822,9 +822,6 @@ exports.ScriptError = function ScriptError(code, op, ip) {
|
||||
|
||||
Error.call(this);
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, ScriptError);
|
||||
|
||||
this.type = 'ScriptError';
|
||||
this.code = code;
|
||||
this.message = code;
|
||||
@ -838,6 +835,9 @@ exports.ScriptError = function ScriptError(code, op, ip) {
|
||||
this.op = op.value;
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, ScriptError);
|
||||
};
|
||||
|
||||
util.inherits(exports.ScriptError, Error);
|
||||
|
||||
@ -1031,13 +1031,16 @@ encoding.sizeVarString = function sizeVarString(str, enc) {
|
||||
*/
|
||||
|
||||
encoding.EncodingError = function EncodingError(offset, reason) {
|
||||
Error.call(this);
|
||||
if (!(this instanceof EncodingError))
|
||||
return new EncodingError(offset, reason);
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, EncodingError);
|
||||
Error.call(this);
|
||||
|
||||
this.type = 'EncodingError';
|
||||
this.message = `${reason} (offset=${offset}).`;
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, EncodingError);
|
||||
};
|
||||
|
||||
inherits(encoding.EncodingError, Error);
|
||||
|
||||
@ -599,13 +599,16 @@ function inherits(child, parent) {
|
||||
}
|
||||
|
||||
function ValidationError(key, type) {
|
||||
Error.call(this);
|
||||
if (!(this instanceof ValidationError))
|
||||
return new ValidationError(key, type);
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, ValidationError);
|
||||
Error.call(this);
|
||||
|
||||
this.type = 'ValidationError';
|
||||
this.message = `${fmt(key)} must be a ${type}.`;
|
||||
|
||||
if (Error.captureStackTrace)
|
||||
Error.captureStackTrace(this, ValidationError);
|
||||
}
|
||||
|
||||
inherits(ValidationError, Error);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user