mirror of
https://github.com/Ride-The-Lightning/RTL.git
synced 2025-01-19 05:33:33 +01:00
Merge pull request #1196 from Ride-The-Lightning/enhanced-error-message
Updated error handling function
This commit is contained in:
commit
01ee444941
@ -219,7 +219,11 @@ export class CommonService {
|
||||
}
|
||||
};
|
||||
this.handleError = (errRes, fileName, errMsg, selectedNode) => {
|
||||
const err = JSON.parse(JSON.stringify(errRes));
|
||||
let err = JSON.parse(JSON.stringify(errRes));
|
||||
if (Object.keys(err.error).length === 0 && errRes.error && (errRes.error.stack || errRes.error.message)) {
|
||||
errRes.error = errRes.error.stack || errRes.error.message;
|
||||
err = JSON.parse(JSON.stringify(errRes));
|
||||
}
|
||||
if (!selectedNode) {
|
||||
selectedNode = this.initSelectedNode;
|
||||
}
|
||||
@ -254,7 +258,7 @@ export class CommonService {
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.logger.log({ selectedNode: selectedNode, level: 'ERROR', fileName: fileName, msg: errMsg, error: (typeof err === 'object' ? JSON.stringify(err) : (typeof err === 'string') ? err : 'Unknown Error') });
|
||||
this.logger.log({ selectedNode: selectedNode, level: 'ERROR', fileName: fileName, msg: errMsg, error: (typeof err === 'object' ? JSON.stringify(err) : err) });
|
||||
let newErrorObj = { statusCode: 500, message: '', error: '' };
|
||||
if (err.code && err.code === 'ENOENT') {
|
||||
newErrorObj = {
|
||||
|
@ -236,7 +236,11 @@ export class CommonService {
|
||||
};
|
||||
|
||||
public handleError = (errRes, fileName, errMsg, selectedNode: CommonSelectedNode) => {
|
||||
const err = JSON.parse(JSON.stringify(errRes));
|
||||
let err = JSON.parse(JSON.stringify(errRes));
|
||||
if (Object.keys(err.error).length === 0 && errRes.error && (errRes.error.stack || errRes.error.message)) {
|
||||
errRes.error = errRes.error.stack || errRes.error.message;
|
||||
err = JSON.parse(JSON.stringify(errRes));
|
||||
}
|
||||
if (!selectedNode) { selectedNode = this.initSelectedNode; }
|
||||
switch (selectedNode.ln_implementation) {
|
||||
case 'LND':
|
||||
@ -270,7 +274,7 @@ export class CommonService {
|
||||
if (err.options && err.options.headers) { delete err.options.headers; }
|
||||
break;
|
||||
}
|
||||
this.logger.log({ selectedNode: selectedNode, level: 'ERROR', fileName: fileName, msg: errMsg, error: (typeof err === 'object' ? JSON.stringify(err) : (typeof err === 'string') ? err : 'Unknown Error') });
|
||||
this.logger.log({ selectedNode: selectedNode, level: 'ERROR', fileName: fileName, msg: errMsg, error: (typeof err === 'object' ? JSON.stringify(err) : err) });
|
||||
let newErrorObj = { statusCode: 500, message: '', error: '' };
|
||||
if (err.code && err.code === 'ENOENT') {
|
||||
newErrorObj = {
|
||||
|
Loading…
Reference in New Issue
Block a user