Require message field too

This commit is contained in:
Henry Mercer
2025-10-21 10:27:54 +01:00
parent a6b9514fab
commit 40e26468f3
10 changed files with 34 additions and 0 deletions

View File

@@ -693,6 +693,13 @@ export class ConfigurationError extends Error {
}
export function asHTTPError(arg: any): HTTPError | undefined {
if (
typeof arg !== "object" ||
arg === null ||
typeof arg.message !== "string"
) {
return undefined;
}
if (Number.isInteger(arg.status)) {
return new HTTPError(arg.message as string, arg.status as number);
}