Added Syntax error case and also default error returning (#4015)
This commit is contained in:
1 parent
d75a8910f6
commit
3527c5126a
1 file changed
+10
-1
@@ -33,6 +33,12 @@ export function getServerErrorFromUnknown(cause: unknown): HttpError {
|
||||
cause,
|
||||
});
|
||||
}
|
||||
if (cause instanceof SyntaxError) {
|
||||
return new HttpError({
|
||||
statusCode: 500,
|
||||
message: "Unexpected error, please reach out for our customer support.",
|
||||
});
|
||||
}
|
||||
if (cause instanceof PrismaClientKnownRequestError) {
|
||||
return new HttpError({ statusCode: 400, message: cause.message, cause });
|
||||
}
|
||||
@@ -50,5 +56,8 @@ export function getServerErrorFromUnknown(cause: unknown): HttpError {
|
||||
return new Error(cause, { cause });
|
||||
}
|
||||
|
||||
return new HttpError({ statusCode: 500, message: `Unhandled error of type '${typeof cause}'` });
|
||||
return new HttpError({
|
||||
statusCode: 500,
|
||||
message: `Unhandled error of type '${typeof cause}'. Please reach out for our customer support.`,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user