mirror of
https://github.com/smogon/pokemon-showdown-loginserver.git
synced 2026-03-21 17:34:38 -05:00
Properly intercept ErrorMessages
Instanceof is bad, kids.
This commit is contained in:
parent
bdc78dcf91
commit
843728fe08
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user