From 43f89216ae7120c8838f10fd7ccb8241e54eba39 Mon Sep 17 00:00:00 2001 From: m5r Date: Sat, 28 Aug 2021 02:05:44 +0800 Subject: [PATCH] type caught error to any --- app/api/newsletter/subscribe.ts | 4 ++-- app/auth/components/login-form.tsx | 2 +- app/auth/components/signup-form.tsx | 2 +- app/auth/pages/forgot-password.tsx | 2 +- app/auth/pages/reset-password.tsx | 2 +- app/core/mutations/set-notification-subscription.ts | 2 +- app/messages/api/queue/notify-incoming-message.ts | 2 +- app/messages/api/queue/send-message.ts | 2 +- app/messages/api/webhook/incoming-message.ts | 2 +- app/messages/mutations/send-message.ts | 2 +- app/settings/components/profile-informations.tsx | 2 +- app/settings/components/update-password.tsx | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/api/newsletter/subscribe.ts b/app/api/newsletter/subscribe.ts index 20ad8f3..0cc60ea 100644 --- a/app/api/newsletter/subscribe.ts +++ b/app/api/newsletter/subscribe.ts @@ -30,7 +30,7 @@ export default async function subscribeToNewsletter(req: BlitzApiRequest, res: B let body; try { body = bodySchema.parse(req.body); - } catch (error) { + } catch (error: any) { const statusCode = 400; const apiError: ApiError = { statusCode, @@ -44,7 +44,7 @@ export default async function subscribeToNewsletter(req: BlitzApiRequest, res: B try { await addSubscriber(body.email); - } catch (error) { + } catch (error: any) { console.log("error", error.response?.data); if (error.response?.data.title !== "Member Exists") { diff --git a/app/auth/components/login-form.tsx b/app/auth/components/login-form.tsx index 1444712..1bcad80 100644 --- a/app/auth/components/login-form.tsx +++ b/app/auth/components/login-form.tsx @@ -24,7 +24,7 @@ export const LoginForm = (props: LoginFormProps) => { try { await loginMutation(values); props.onSuccess?.(); - } catch (error) { + } catch (error: any) { if (error instanceof AuthenticationError) { return { [FORM_ERROR]: "Sorry, those credentials are invalid" }; } else { diff --git a/app/auth/components/signup-form.tsx b/app/auth/components/signup-form.tsx index 594fe16..19e1fba 100644 --- a/app/auth/components/signup-form.tsx +++ b/app/auth/components/signup-form.tsx @@ -24,7 +24,7 @@ export const SignupForm = (props: SignupFormProps) => { try { await signupMutation(values); props.onSuccess?.(); - } catch (error) { + } catch (error: any) { if (error.code === "P2002" && error.meta?.target?.includes("email")) { // This error comes from Prisma return { email: "This email is already being used" }; diff --git a/app/auth/pages/forgot-password.tsx b/app/auth/pages/forgot-password.tsx index c5f7b39..398793e 100644 --- a/app/auth/pages/forgot-password.tsx +++ b/app/auth/pages/forgot-password.tsx @@ -27,7 +27,7 @@ const ForgotPasswordPage: BlitzPage = () => { onSubmit={async (values) => { try { await forgotPasswordMutation(values); - } catch (error) { + } catch (error: any) { return { [FORM_ERROR]: "Sorry, we had an unexpected error. Please try again.", }; diff --git a/app/auth/pages/reset-password.tsx b/app/auth/pages/reset-password.tsx index 56ba921..b2c49dc 100644 --- a/app/auth/pages/reset-password.tsx +++ b/app/auth/pages/reset-password.tsx @@ -34,7 +34,7 @@ const ResetPasswordPage: BlitzPage = () => { onSubmit={async (values) => { try { await resetPasswordMutation(values); - } catch (error) { + } catch (error: any) { if (error.name === "ResetPasswordError") { return { [FORM_ERROR]: error.message, diff --git a/app/core/mutations/set-notification-subscription.ts b/app/core/mutations/set-notification-subscription.ts index ae6c209..52a4765 100644 --- a/app/core/mutations/set-notification-subscription.ts +++ b/app/core/mutations/set-notification-subscription.ts @@ -45,7 +45,7 @@ export default resolver.pipe( keys_auth: subscription.keys.auth, }, }); - } catch (error) { + } catch (error: any) { if (error.code !== "P2002") { logger.error(error); // we might want to `throw error`; diff --git a/app/messages/api/queue/notify-incoming-message.ts b/app/messages/api/queue/notify-incoming-message.ts index 830303a..68f6499 100644 --- a/app/messages/api/queue/notify-incoming-message.ts +++ b/app/messages/api/queue/notify-incoming-message.ts @@ -49,7 +49,7 @@ const notifyIncomingMessageQueue = Queue( try { await webpush.sendNotification(webPushSubscription, JSON.stringify(notification)); - } catch (error) { + } catch (error: any) { logger.error(error); if (error instanceof WebPushError) { // subscription most likely expired or has been revoked diff --git a/app/messages/api/queue/send-message.ts b/app/messages/api/queue/send-message.ts index 395cd64..5ae545c 100644 --- a/app/messages/api/queue/send-message.ts +++ b/app/messages/api/queue/send-message.ts @@ -33,7 +33,7 @@ const sendMessageQueue = Queue( where: { organizationId_phoneNumberId_id: { id, organizationId, phoneNumberId } }, data: { id: message.sid }, }); - } catch (error) { + } catch (error: any) { // TODO: handle twilio error console.log(error.code); // 21211 console.log(error.moreInfo); // https://www.twilio.com/docs/errors/21211 diff --git a/app/messages/api/webhook/incoming-message.ts b/app/messages/api/webhook/incoming-message.ts index 3629f4c..7906f97 100644 --- a/app/messages/api/webhook/incoming-message.ts +++ b/app/messages/api/webhook/incoming-message.ts @@ -84,7 +84,7 @@ export default async function incomingMessageHandler(req: BlitzApiRequest, res: res.setHeader("content-type", "text/html"); res.status(200).send(""); - } catch (error) { + } catch (error: any) { const statusCode = error.statusCode ?? 500; const apiError: ApiError = { statusCode, diff --git a/app/messages/mutations/send-message.ts b/app/messages/mutations/send-message.ts index d3f1418..d1e0e5e 100644 --- a/app/messages/mutations/send-message.ts +++ b/app/messages/mutations/send-message.ts @@ -29,7 +29,7 @@ export default resolver.pipe(resolver.zod(Body), resolver.authorize(), async ({ try { await twilio(organization.twilioAccountSid, organization.twilioAuthToken).lookups.v1.phoneNumbers(to).fetch(); - } catch (error) { + } catch (error: any) { logger.error(error); return; } diff --git a/app/settings/components/profile-informations.tsx b/app/settings/components/profile-informations.tsx index cf99ac0..6dbbf3e 100644 --- a/app/settings/components/profile-informations.tsx +++ b/app/settings/components/profile-informations.tsx @@ -41,7 +41,7 @@ const ProfileInformations: FunctionComponent = () => { try { // TODO // await updateUser({ email, data: { name } }); - } catch (error) { + } catch (error: any) { logger.error(error.response, "error updating user infos"); if (error.response.status === 401) { diff --git a/app/settings/components/update-password.tsx b/app/settings/components/update-password.tsx index 8679a8e..48ca2de 100644 --- a/app/settings/components/update-password.tsx +++ b/app/settings/components/update-password.tsx @@ -38,7 +38,7 @@ const UpdatePassword: FunctionComponent = () => { try { // TODO // await customer.updateUser({ password: newPassword }); - } catch (error) { + } catch (error: any) { logger.error(error.response, "error updating user infos"); if (error.response.status === 401) {