fix error boundary error handling

This commit is contained in:
m5r 2021-08-01 19:21:49 +08:00
parent 95488456d9
commit fdf9df243b
2 changed files with 12 additions and 12 deletions

View File

@ -4,14 +4,14 @@ import db from "db";
import twilio from "twilio";
export default async function ddd(req: BlitzApiRequest, res: BlitzApiResponse) {
/*await Promise.all([
await Promise.all([
db.message.deleteMany(),
db.phoneCall.deleteMany(),
db.phoneNumber.deleteMany(),
db.customer.deleteMany(),
]);
await db.user.deleteMany();*/
await db.user.deleteMany();
const accountSid = "ACa886d066be0832990d1cf43fb1d53362";
const authToken = "8696a59a64b94bb4eba3548ed815953b";
/*const ddd = await twilio(accountSid, authToken)
@ -32,11 +32,11 @@ export default async function ddd(req: BlitzApiRequest, res: BlitzApiResponse) {
console.log(error.details);
// console.log(JSON.stringify(Object.keys(error)));
}*/
const ddd = await twilio(accountSid, authToken).messages.create({
/*const ddd = await twilio(accountSid, authToken).messages.create({
body: "content",
to: "+33757592025",
from: "+33757592722",
});
});*/
res.status(200).send(ddd);
res.status(200).end();
}

View File

@ -60,12 +60,12 @@ type ErrorBoundaryState =
errorMessage: string;
};
const blitzErrorNames = [
RedirectError.name,
AuthenticationError.name,
AuthorizationError.name,
CSRFTokenMismatchError.name,
NotFoundError.name,
const blitzErrors = [
RedirectError,
AuthenticationError,
AuthorizationError,
CSRFTokenMismatchError,
NotFoundError,
];
const ErrorBoundary = withRouter(
@ -83,7 +83,7 @@ const ErrorBoundary = withRouter(
public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
logger.error(error, errorInfo.componentStack);
if (blitzErrorNames.includes(error.name)) {
if (blitzErrors.some((blitzError) => error instanceof blitzError)) {
// let Blitz ErrorBoundary handle this one
throw error;
}