mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Merge pull request #610 from darkdarkdragon/develop-RLJS-534
fix error in remote.createPathFind
This commit is contained in:
@@ -1,15 +1,39 @@
|
||||
/* eslint-disable valid-jsdoc */
|
||||
'use strict';
|
||||
|
||||
const util = require('util');
|
||||
const utils = require('./utils');
|
||||
|
||||
/**
|
||||
* Base class for all errors
|
||||
*/
|
||||
function RippleError(message) {
|
||||
this.message = message;
|
||||
}
|
||||
RippleError.prototype = new Error();
|
||||
|
||||
RippleError.prototype = Object.create(Error.prototype);
|
||||
RippleError.prototype.name = 'RippleError';
|
||||
|
||||
|
||||
RippleError.prototype.toString = function() {
|
||||
let result = '[' + this.name + '(' + this.message;
|
||||
if (this.data) {
|
||||
result += ', ' + util.inspect(this.data);
|
||||
}
|
||||
result += ')]';
|
||||
return result;
|
||||
};
|
||||
|
||||
/*
|
||||
console.log in node uses util.inspect on object, and util.inspect allows
|
||||
to cutomize it output:
|
||||
https://nodejs.org/api/util.html#util_custom_inspect_function_on_objects
|
||||
*/
|
||||
RippleError.prototype.inspect = function(depth) {
|
||||
utils.unused(depth);
|
||||
return this.toString();
|
||||
};
|
||||
|
||||
function ValidationError(message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@@ -1871,7 +1871,8 @@ Remote.prototype.createPathFind = function(options, callback) {
|
||||
|
||||
if (callback) {
|
||||
const updateTimeout = setTimeout(() => {
|
||||
callback(new RippleError('tejTimeout'));
|
||||
callback(new RippleError('tejTimeout',
|
||||
'createPathFind request timed out'));
|
||||
pathFind.close();
|
||||
this._cur_path_find = null;
|
||||
}, this.pathfind_timeout);
|
||||
@@ -1894,7 +1895,8 @@ Remote.prototype.createPathFind = function(options, callback) {
|
||||
}
|
||||
}
|
||||
});
|
||||
pathFind.on('error', (error) => {
|
||||
pathFind.once('error', (error) => {
|
||||
clearTimeout(updateTimeout);
|
||||
this._cur_path_find = null;
|
||||
callback(error);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const util = require('util');
|
||||
const utils = require('./utils');
|
||||
const _ = require('lodash');
|
||||
|
||||
function RippleError(code?: any, message?: string) {
|
||||
@@ -20,10 +21,14 @@ function RippleError(code?: any, message?: string) {
|
||||
}
|
||||
}
|
||||
|
||||
this.result =
|
||||
_.get(this, ['remote', 'error'], this.result);
|
||||
this.result_message =
|
||||
_.get(this, ['remote', 'error_message'], this.result_message);
|
||||
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.engine_result_message || this.error_message || this.result || 'Error');
|
||||
this.message = this.result_message;
|
||||
|
||||
let stack;
|
||||
@@ -42,4 +47,25 @@ util.inherits(RippleError, Error);
|
||||
|
||||
RippleError.prototype.name = 'RippleError';
|
||||
|
||||
|
||||
RippleError.prototype.toString = function() {
|
||||
let result = '[RippleError(' + this.result;
|
||||
if (this.result_message && this.result_message !== this.result) {
|
||||
result += ', ' + this.result_message;
|
||||
}
|
||||
result += ')]';
|
||||
return result;
|
||||
};
|
||||
|
||||
/*
|
||||
console.log in node uses util.inspect on object, and util.inspect allows
|
||||
to cutomize it output:
|
||||
https://nodejs.org/api/util.html#util_custom_inspect_function_on_objects
|
||||
*/
|
||||
RippleError.prototype.inspect = function(depth) {
|
||||
utils.unused(depth);
|
||||
return this.toString();
|
||||
};
|
||||
|
||||
|
||||
exports.RippleError = RippleError;
|
||||
|
||||
@@ -156,6 +156,9 @@ function fromTimestamp(timestamp) {
|
||||
return Math.round(timestamp_ / 1000) - 0x386D4380;
|
||||
}
|
||||
|
||||
function unused() {
|
||||
}
|
||||
|
||||
exports.time = {
|
||||
fromRipple: toTimestamp,
|
||||
toRipple: fromTimestamp
|
||||
@@ -176,5 +179,6 @@ exports.toTimestamp = toTimestamp;
|
||||
exports.fromTimestamp = fromTimestamp;
|
||||
exports.getMantissaDecimalString = getMantissaDecimalString;
|
||||
exports.getMantissa16FromString = getMantissa16FromString;
|
||||
exports.unused = unused;
|
||||
|
||||
// vim:sw=2:sts=2:ts=8:et
|
||||
|
||||
Reference in New Issue
Block a user