Properly intercept ErrorMessages
Some checks failed
Node.js CI / build (16.x) (push) Has been cancelled
Node.js CI / build (20.x) (push) Has been cancelled

Instanceof is bad, kids.
This commit is contained in:
Mia 2025-01-24 16:07:18 -06:00
parent bdc78dcf91
commit 843728fe08

View File

@ -112,7 +112,7 @@ export class ActionContext {
return result;
} catch (e: any) {
if (e instanceof ActionError) {
if (e?.name?.endsWith('ActionError')) {
return {actionerror: e.message};
}
@ -384,7 +384,7 @@ export class Server {
res.writeHead(200).end(this.stringify(result, useDispatchPrefix));
} catch (e: any) {
this.ensureHeaders(res);
if (e instanceof ActionError) {
if (e?.name?.endsWith('ActionError')) {
if (e.httpStatus) {
res.writeHead(e.httpStatus).end('Error: ' + e.message);
} else {