From 454d52a46a28f8ea4df2efc265d5ba901067e8dd Mon Sep 17 00:00:00 2001 From: Deepak Prabhakara Date: Mon, 23 Dec 2024 13:46:21 +0000 Subject: [PATCH] error -> err in catch blocks for consistency --- ee/branding/api/index.ts | 4 ++-- ee/identity-federation/api/metadata.ts | 4 ++-- ee/product/api/[productId].ts | 4 ++-- ee/product/api/index.ts | 4 ++-- .../EditIdentityFederationApp.tsx | 4 ++-- lib/api/default.ts | 6 +++--- npm/src/db/dynamoDb.ts | 16 ++++++++-------- npm/src/directory-sync/batch-events/queue.ts | 8 ++++---- npm/src/directory-sync/non-scim/google/oauth.ts | 12 ++++++------ pages/api/oauth/saml.ts | 6 +++--- pages/api/scim/oauth/authorize.ts | 4 ++-- pages/api/scim/oauth/callback.ts | 4 ++-- .../directory-sync/[directoryId]/index.ts | 4 ++-- pages/api/setup/[token]/directory-sync/index.ts | 4 ++-- pages/api/setup/[token]/index.ts | 4 ++-- pages/api/setup/[token]/sso-connection/[id].ts | 4 ++-- .../setup/[token]/sso-connection/idp-entityid.ts | 4 ++-- pages/setup/[token]/sso-connection/new.tsx | 2 +- 18 files changed, 49 insertions(+), 49 deletions(-) diff --git a/ee/branding/api/index.ts b/ee/branding/api/index.ts index 5d441758f..1858bd120 100644 --- a/ee/branding/api/index.ts +++ b/ee/branding/api/index.ts @@ -15,8 +15,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { res.setHeader('Allow', 'GET'); res.status(405).json({ error: { message: `Method ${method} Not Allowed` } }); } - } catch (error: any) { - const { message, statusCode = 500 } = error; + } catch (err: any) { + const { message, statusCode = 500 } = err; res.status(statusCode).json({ error: { message } }); } diff --git a/ee/identity-federation/api/metadata.ts b/ee/identity-federation/api/metadata.ts index 96234b129..6c40ea088 100644 --- a/ee/identity-federation/api/metadata.ts +++ b/ee/identity-federation/api/metadata.ts @@ -32,8 +32,8 @@ const handleGET = async (req: NextApiRequest, res: NextApiResponse) => { } res.status(200).send(metadata.xml); - } catch (error: any) { - const { message, statusCode = 500 } = error; + } catch (err: any) { + const { message, statusCode = 500 } = err; return res.status(statusCode).json({ error: { message }, diff --git a/ee/product/api/[productId].ts b/ee/product/api/[productId].ts index a3006a0cf..4e7db4074 100644 --- a/ee/product/api/[productId].ts +++ b/ee/product/api/[productId].ts @@ -15,8 +15,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { res.setHeader('Allow', 'GET,DELETE'); res.status(405).json({ error: { message: `Method ${req.method} Not Allowed` } }); } - } catch (error: any) { - const { message, statusCode = 500 } = error; + } catch (err: any) { + const { message, statusCode = 500 } = err; res.status(statusCode).json({ error: { message } }); } }; diff --git a/ee/product/api/index.ts b/ee/product/api/index.ts index 2e4dbafe8..1392fac2e 100644 --- a/ee/product/api/index.ts +++ b/ee/product/api/index.ts @@ -12,8 +12,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { res.setHeader('Allow', 'POST'); res.status(405).json({ error: { message: `Method ${req.method} Not Allowed` } }); } - } catch (error: any) { - const { message, statusCode = 500 } = error; + } catch (err: any) { + const { message, statusCode = 500 } = err; res.status(statusCode).json({ error: { message } }); } }; diff --git a/internal-ui/src/identity-federation/EditIdentityFederationApp.tsx b/internal-ui/src/identity-federation/EditIdentityFederationApp.tsx index f08de33a8..c0496247e 100644 --- a/internal-ui/src/identity-federation/EditIdentityFederationApp.tsx +++ b/internal-ui/src/identity-federation/EditIdentityFederationApp.tsx @@ -55,8 +55,8 @@ export const EditIdentityFederationApp = ({ await fetch(urls.deleteApp, { method: 'DELETE', headers: defaultHeaders }); setDelModalVisible(false); onDelete?.(); - } catch (error: any) { - onError?.(error); + } catch (err: any) { + onError?.(err); } }; diff --git a/lib/api/default.ts b/lib/api/default.ts index eab91d073..ae8ab324e 100644 --- a/lib/api/default.ts +++ b/lib/api/default.ts @@ -21,9 +21,9 @@ export const defaultHandler = async (req: NextApiRequest, res: NextApiResponse, // Call the handler await handler(req, res); return; - } catch (error: any) { - const message = error.message || 'Internal Server Error'; - const status = error.statusCode || 500; + } catch (err: any) { + const message = err.message || 'Internal Server Error'; + const status = err.statusCode || 500; console.error(`${req.method} ${req.url} - ${status} - ${message}`); diff --git a/npm/src/db/dynamoDb.ts b/npm/src/db/dynamoDb.ts index 685efe77a..fe207cfc7 100644 --- a/npm/src/db/dynamoDb.ts +++ b/npm/src/db/dynamoDb.ts @@ -73,12 +73,12 @@ class DynamoDB implements DatabaseDriver { }, }) ); - } catch (error: any) { + } catch (err: any) { if ( - !error?.message?.includes('Cannot create preexisting table') && - !error?.message?.toLowerCase().includes('table already exists') + !err?.message?.includes('Cannot create preexisting table') && + !err?.message?.toLowerCase().includes('table already exists') ) { - throw error; + throw err; } } try { @@ -145,12 +145,12 @@ class DynamoDB implements DatabaseDriver { TableName: indexTableName, }) ); - } catch (error: any) { + } catch (err: any) { if ( - !error?.message?.includes('Cannot create preexisting table') && - !error?.message?.toLowerCase().includes('table already exists') + !err?.message?.includes('Cannot create preexisting table') && + !err?.message?.toLowerCase().includes('table already exists') ) { - throw error; + throw err; } } return this; diff --git a/npm/src/directory-sync/batch-events/queue.ts b/npm/src/directory-sync/batch-events/queue.ts index ca010d6c9..ec4c7604f 100644 --- a/npm/src/directory-sync/batch-events/queue.ts +++ b/npm/src/directory-sync/batch-events/queue.ts @@ -153,11 +153,11 @@ export class EventProcessor { } await this.logWebhookEvent(directory, events, status); - } catch (error: any) { - const message = `Error sending payload to webhook ${directory.webhook.endpoint}. Marking the events as failed. ${error.message}`; - const status = error.response?.status || 500; + } catch (err: any) { + const message = `Error sending payload to webhook ${directory.webhook.endpoint}. Marking the events as failed. ${err.message}`; + const status = err.response?.status || 500; - console.error(message, error); + console.error(message, err); await this.markAsFailed(events); await this.logWebhookEvent(directory, events, status); diff --git a/npm/src/directory-sync/non-scim/google/oauth.ts b/npm/src/directory-sync/non-scim/google/oauth.ts index 6a487277f..2cc4718ab 100644 --- a/npm/src/directory-sync/non-scim/google/oauth.ts +++ b/npm/src/directory-sync/non-scim/google/oauth.ts @@ -71,8 +71,8 @@ export class GoogleAuth { }; return { data, error: null }; - } catch (error: any) { - return apiError(error); + } catch (err: any) { + return apiError(err); } } @@ -92,8 +92,8 @@ export class GoogleAuth { const { tokens } = await oauth2Client.getToken(code); return { data: tokens, error: null }; - } catch (error: any) { - return apiError(error); + } catch (err: any) { + return apiError(err); } } @@ -124,8 +124,8 @@ export class GoogleAuth { } return { data, error: null }; - } catch (error: any) { - return apiError(error); + } catch (err: any) { + return apiError(err); } } } diff --git a/pages/api/oauth/saml.ts b/pages/api/oauth/saml.ts index bdba902aa..2e9ac79e3 100644 --- a/pages/api/oauth/saml.ts +++ b/pages/api/oauth/saml.ts @@ -45,9 +45,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) res.send(response_form); return; } - } catch (error: any) { - const { message, statusCode = 500 } = error; - console.error('Error processing SAML IdP response:', message); + } catch (err: any) { + const { message, statusCode = 500 } = err; + console.error('Error processing SAML IdP response:', err); setErrorCookie(res, { message, statusCode }, { path: '/error' }); diff --git a/pages/api/scim/oauth/authorize.ts b/pages/api/scim/oauth/authorize.ts index 3798393e9..418bf5f70 100644 --- a/pages/api/scim/oauth/authorize.ts +++ b/pages/api/scim/oauth/authorize.ts @@ -27,8 +27,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { res.redirect(302, data.authorizationUrl).end(); return; - } catch (error: any) { - const { message, statusCode = 500 } = error; + } catch (err: any) { + const { message, statusCode = 500 } = err; return res.status(statusCode).json({ error: { message } }); } diff --git a/pages/api/scim/oauth/callback.ts b/pages/api/scim/oauth/callback.ts index 30a646577..b715b1566 100644 --- a/pages/api/scim/oauth/callback.ts +++ b/pages/api/scim/oauth/callback.ts @@ -45,8 +45,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { } return res.send('Authorized done successfully. You may close this window.'); - } catch (error: any) { - return res.status(500).send({ error }); + } catch (err: any) { + return res.status(500).send({ err }); } }; diff --git a/pages/api/setup/[token]/directory-sync/[directoryId]/index.ts b/pages/api/setup/[token]/directory-sync/[directoryId]/index.ts index 2a816eef9..7c858cf3e 100644 --- a/pages/api/setup/[token]/directory-sync/[directoryId]/index.ts +++ b/pages/api/setup/[token]/directory-sync/[directoryId]/index.ts @@ -21,8 +21,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { res.setHeader('Allow', 'PATCH, GET, DELETE'); res.status(405).json({ error: { message: `Method ${method} Not Allowed` } }); } - } catch (error: any) { - const { message, statusCode = 500 } = error; + } catch (err: any) { + const { message, statusCode = 500 } = err; return res.status(statusCode).json({ error: { message } }); } diff --git a/pages/api/setup/[token]/directory-sync/index.ts b/pages/api/setup/[token]/directory-sync/index.ts index 9b1e29dd5..a322f364f 100644 --- a/pages/api/setup/[token]/directory-sync/index.ts +++ b/pages/api/setup/[token]/directory-sync/index.ts @@ -21,8 +21,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { res.setHeader('Allow', 'PUT'); res.status(405).json({ error: { message: `Method ${method} Not Allowed` } }); } - } catch (error: any) { - const { message, statusCode = 500 } = error; + } catch (err: any) { + const { message, statusCode = 500 } = err; return res.status(statusCode).json({ error: { message } }); } diff --git a/pages/api/setup/[token]/index.ts b/pages/api/setup/[token]/index.ts index 6e7fe674b..e94b14747 100644 --- a/pages/api/setup/[token]/index.ts +++ b/pages/api/setup/[token]/index.ts @@ -14,8 +14,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { res.setHeader('Allow', 'GET'); res.status(405).json({ error: { message: `Method ${method} Not Allowed` } }); } - } catch (error: any) { - const { message, statusCode = 500 } = error; + } catch (err: any) { + const { message, statusCode = 500 } = err; return res.status(statusCode).json({ error: { message } }); } diff --git a/pages/api/setup/[token]/sso-connection/[id].ts b/pages/api/setup/[token]/sso-connection/[id].ts index 17a63c5eb..ba5c8af19 100644 --- a/pages/api/setup/[token]/sso-connection/[id].ts +++ b/pages/api/setup/[token]/sso-connection/[id].ts @@ -17,8 +17,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { res.setHeader('Allow', 'GET'); res.status(405).json({ error: { message: `Method ${method} Not Allowed` } }); } - } catch (error: any) { - const { message, statusCode = 500 } = error; + } catch (err: any) { + const { message, statusCode = 500 } = err; return res.status(statusCode).json({ error: { message } }); } diff --git a/pages/api/setup/[token]/sso-connection/idp-entityid.ts b/pages/api/setup/[token]/sso-connection/idp-entityid.ts index 29170a485..8e682982b 100644 --- a/pages/api/setup/[token]/sso-connection/idp-entityid.ts +++ b/pages/api/setup/[token]/sso-connection/idp-entityid.ts @@ -18,8 +18,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { res.setHeader('Allow', 'GET'); res.status(405).json({ error: { message: `Method ${method} Not Allowed` } }); } - } catch (error: any) { - const { message, statusCode = 500 } = error; + } catch (err: any) { + const { message, statusCode = 500 } = err; return res.status(statusCode).json({ error: { message } }); } diff --git a/pages/setup/[token]/sso-connection/new.tsx b/pages/setup/[token]/sso-connection/new.tsx index 872e1f1a6..99632efeb 100644 --- a/pages/setup/[token]/sso-connection/new.tsx +++ b/pages/setup/[token]/sso-connection/new.tsx @@ -164,7 +164,7 @@ export async function getServerSideProps({ locale, query }: GetServerSidePropsCo const source = fs.readFileSync(`${mdxDirectory}/${step}.mdx`, 'utf8'); mdxSource = await serialize(source, { mdxOptions: { remarkPlugins: [remarkGfm] } }); // eslint-disable-next-line @typescript-eslint/no-unused-vars - } catch (error: any) { + } catch (err: any) { return { redirect: { destination: `/setup/${token}/sso-connection/new`,