Skip to content

Commit

Permalink
fix: better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
manast committed Sep 18, 2024
1 parent 96a6ff2 commit ced68e3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,15 @@ export class Redbird {
//
// Send a 500 http status if headers have been sent
//
if (err.code === 'ECONNREFUSED') {
res.writeHead && res.writeHead(502);
} else if (!res.headersSent) {
res.writeHead && res.writeHead(500, err.message, { 'content-type': 'text/plain' });
if (!res || !res.writeHead) {
this.log?.error(err, 'Proxy Error');
return;
} else {
if (err.code === 'ECONNREFUSED') {
res.writeHead(502);
} else if (!res.headersSent) {
res.writeHead(500, err.message, { 'content-type': 'text/plain' });
}
}

//
Expand Down

0 comments on commit ced68e3

Please sign in to comment.