type caught error to any

This commit is contained in:
m5r 2021-08-28 02:05:44 +08:00
parent 8765d2b7e5
commit 43f89216ae
12 changed files with 13 additions and 13 deletions

View File

@ -30,7 +30,7 @@ export default async function subscribeToNewsletter(req: BlitzApiRequest, res: B
let body; let body;
try { try {
body = bodySchema.parse(req.body); body = bodySchema.parse(req.body);
} catch (error) { } catch (error: any) {
const statusCode = 400; const statusCode = 400;
const apiError: ApiError = { const apiError: ApiError = {
statusCode, statusCode,
@ -44,7 +44,7 @@ export default async function subscribeToNewsletter(req: BlitzApiRequest, res: B
try { try {
await addSubscriber(body.email); await addSubscriber(body.email);
} catch (error) { } catch (error: any) {
console.log("error", error.response?.data); console.log("error", error.response?.data);
if (error.response?.data.title !== "Member Exists") { if (error.response?.data.title !== "Member Exists") {

View File

@ -24,7 +24,7 @@ export const LoginForm = (props: LoginFormProps) => {
try { try {
await loginMutation(values); await loginMutation(values);
props.onSuccess?.(); props.onSuccess?.();
} catch (error) { } catch (error: any) {
if (error instanceof AuthenticationError) { if (error instanceof AuthenticationError) {
return { [FORM_ERROR]: "Sorry, those credentials are invalid" }; return { [FORM_ERROR]: "Sorry, those credentials are invalid" };
} else { } else {

View File

@ -24,7 +24,7 @@ export const SignupForm = (props: SignupFormProps) => {
try { try {
await signupMutation(values); await signupMutation(values);
props.onSuccess?.(); props.onSuccess?.();
} catch (error) { } catch (error: any) {
if (error.code === "P2002" && error.meta?.target?.includes("email")) { if (error.code === "P2002" && error.meta?.target?.includes("email")) {
// This error comes from Prisma // This error comes from Prisma
return { email: "This email is already being used" }; return { email: "This email is already being used" };

View File

@ -27,7 +27,7 @@ const ForgotPasswordPage: BlitzPage = () => {
onSubmit={async (values) => { onSubmit={async (values) => {
try { try {
await forgotPasswordMutation(values); await forgotPasswordMutation(values);
} catch (error) { } catch (error: any) {
return { return {
[FORM_ERROR]: "Sorry, we had an unexpected error. Please try again.", [FORM_ERROR]: "Sorry, we had an unexpected error. Please try again.",
}; };

View File

@ -34,7 +34,7 @@ const ResetPasswordPage: BlitzPage = () => {
onSubmit={async (values) => { onSubmit={async (values) => {
try { try {
await resetPasswordMutation(values); await resetPasswordMutation(values);
} catch (error) { } catch (error: any) {
if (error.name === "ResetPasswordError") { if (error.name === "ResetPasswordError") {
return { return {
[FORM_ERROR]: error.message, [FORM_ERROR]: error.message,

View File

@ -45,7 +45,7 @@ export default resolver.pipe(
keys_auth: subscription.keys.auth, keys_auth: subscription.keys.auth,
}, },
}); });
} catch (error) { } catch (error: any) {
if (error.code !== "P2002") { if (error.code !== "P2002") {
logger.error(error); logger.error(error);
// we might want to `throw error`; // we might want to `throw error`;

View File

@ -49,7 +49,7 @@ const notifyIncomingMessageQueue = Queue<Payload>(
try { try {
await webpush.sendNotification(webPushSubscription, JSON.stringify(notification)); await webpush.sendNotification(webPushSubscription, JSON.stringify(notification));
} catch (error) { } catch (error: any) {
logger.error(error); logger.error(error);
if (error instanceof WebPushError) { if (error instanceof WebPushError) {
// subscription most likely expired or has been revoked // subscription most likely expired or has been revoked

View File

@ -33,7 +33,7 @@ const sendMessageQueue = Queue<Payload>(
where: { organizationId_phoneNumberId_id: { id, organizationId, phoneNumberId } }, where: { organizationId_phoneNumberId_id: { id, organizationId, phoneNumberId } },
data: { id: message.sid }, data: { id: message.sid },
}); });
} catch (error) { } catch (error: any) {
// TODO: handle twilio error // TODO: handle twilio error
console.log(error.code); // 21211 console.log(error.code); // 21211
console.log(error.moreInfo); // https://www.twilio.com/docs/errors/21211 console.log(error.moreInfo); // https://www.twilio.com/docs/errors/21211

View File

@ -84,7 +84,7 @@ export default async function incomingMessageHandler(req: BlitzApiRequest, res:
res.setHeader("content-type", "text/html"); res.setHeader("content-type", "text/html");
res.status(200).send("<Response></Response>"); res.status(200).send("<Response></Response>");
} catch (error) { } catch (error: any) {
const statusCode = error.statusCode ?? 500; const statusCode = error.statusCode ?? 500;
const apiError: ApiError = { const apiError: ApiError = {
statusCode, statusCode,

View File

@ -29,7 +29,7 @@ export default resolver.pipe(resolver.zod(Body), resolver.authorize(), async ({
try { try {
await twilio(organization.twilioAccountSid, organization.twilioAuthToken).lookups.v1.phoneNumbers(to).fetch(); await twilio(organization.twilioAccountSid, organization.twilioAuthToken).lookups.v1.phoneNumbers(to).fetch();
} catch (error) { } catch (error: any) {
logger.error(error); logger.error(error);
return; return;
} }

View File

@ -41,7 +41,7 @@ const ProfileInformations: FunctionComponent = () => {
try { try {
// TODO // TODO
// await updateUser({ email, data: { name } }); // await updateUser({ email, data: { name } });
} catch (error) { } catch (error: any) {
logger.error(error.response, "error updating user infos"); logger.error(error.response, "error updating user infos");
if (error.response.status === 401) { if (error.response.status === 401) {

View File

@ -38,7 +38,7 @@ const UpdatePassword: FunctionComponent = () => {
try { try {
// TODO // TODO
// await customer.updateUser({ password: newPassword }); // await customer.updateUser({ password: newPassword });
} catch (error) { } catch (error: any) {
logger.error(error.response, "error updating user infos"); logger.error(error.response, "error updating user infos");
if (error.response.status === 401) { if (error.response.status === 401) {