mirror of
https://github.com/ringtools/ringtools-server-ts.git
synced 2024-05-16 05:44:40 +02:00
Handle backend errors
This commit is contained in:
parent
66e7437d17
commit
a33bf5423a
3 changed files with 22 additions and 5 deletions
|
@ -53,8 +53,16 @@ export default class ChannelController {
|
|||
|
||||
try {
|
||||
return await this.lndService.getChannel(request.params.channelId);
|
||||
} catch {
|
||||
return reply.notFound();
|
||||
} catch(e) {
|
||||
if (e.response && e.response.data.code === 2) {
|
||||
return reply.notFound();
|
||||
} else {
|
||||
let msg;
|
||||
if (e.errno && e.errno === -3008) {
|
||||
msg = "Backend can not be reached";
|
||||
}
|
||||
return reply.internalServerError(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,8 +42,16 @@ export default class NodeController {
|
|||
|
||||
try {
|
||||
return await this.lndService.getNode(request.params.pubKey);
|
||||
} catch {
|
||||
return reply.notFound();
|
||||
} catch(e) {
|
||||
if (e.response && e.response.data.code === 5) {
|
||||
return reply.notFound();
|
||||
} else {
|
||||
let msg;
|
||||
if (e.errno && e.errno === -3008) {
|
||||
msg = "Backend can not be reached";
|
||||
}
|
||||
return reply.internalServerError(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,8 @@ export class LndService {
|
|||
this.ws.send('{}');
|
||||
});
|
||||
this.ws.on('error', (err: Error) => {
|
||||
console.log(`Error: ${err}`);
|
||||
console.log(err);
|
||||
console.log(`WS Error: ${err}`);
|
||||
});
|
||||
this.ws.on('ping', (_event: Buffer) => {});
|
||||
this.ws.on('message', (event: WebSocket.RawData) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue