mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
copy message from Error instance into RippleError
This commit is contained in:
@@ -1,23 +1,28 @@
|
||||
var util = require('util');
|
||||
var extend = require('extend');
|
||||
const util = require('util');
|
||||
const _ = require('lodash');
|
||||
|
||||
function RippleError(code, message) {
|
||||
switch (typeof code) {
|
||||
case 'object':
|
||||
extend(this, code);
|
||||
break;
|
||||
function RippleError(code?: any, message?: string) {
|
||||
if (code instanceof Error) {
|
||||
this.result = code;
|
||||
this.result_message = code.message;
|
||||
} else {
|
||||
switch (typeof code) {
|
||||
case 'object':
|
||||
_.extend(this, code);
|
||||
break;
|
||||
|
||||
case 'string':
|
||||
this.result = code;
|
||||
this.result_message = message;
|
||||
break;
|
||||
case 'string':
|
||||
this.result = code;
|
||||
this.result_message = message;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.engine_result = this.result = (this.result || this.engine_result || this.error || 'Error');
|
||||
this.engine_result_message = this.result_message = (this.result_message || this.engine_result_message || this.error_message || 'Error');
|
||||
this.result_message = this.message = (this.result_message);
|
||||
this.message = this.result_message;
|
||||
|
||||
var stack;
|
||||
let stack;
|
||||
|
||||
if (!!Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, code || this);
|
||||
|
||||
Reference in New Issue
Block a user