Skip to content

Commit

Permalink
error -> err in catch blocks for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakprabhakara committed Dec 23, 2024
1 parent 758ca0d commit 454d52a
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 49 deletions.
4 changes: 2 additions & 2 deletions ee/branding/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
}
Expand Down
4 changes: 2 additions & 2 deletions ee/identity-federation/api/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
4 changes: 2 additions & 2 deletions ee/product/api/[productId].ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
}
};
Expand Down
4 changes: 2 additions & 2 deletions ee/product/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down
6 changes: 3 additions & 3 deletions lib/api/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);

Expand Down
16 changes: 8 additions & 8 deletions npm/src/db/dynamoDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions npm/src/directory-sync/batch-events/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions npm/src/directory-sync/non-scim/google/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export class GoogleAuth {
};

return { data, error: null };
} catch (error: any) {
return apiError(error);
} catch (err: any) {
return apiError(err);
}
}

Expand All @@ -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);
}
}

Expand Down Expand Up @@ -124,8 +124,8 @@ export class GoogleAuth {
}

return { data, error: null };
} catch (error: any) {
return apiError(error);
} catch (err: any) {
return apiError(err);
}
}
}
6 changes: 3 additions & 3 deletions pages/api/oauth/saml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });

Expand Down
4 changes: 2 additions & 2 deletions pages/api/scim/oauth/authorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
}
Expand Down
4 changes: 2 additions & 2 deletions pages/api/scim/oauth/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
};

Expand Down
4 changes: 2 additions & 2 deletions pages/api/setup/[token]/directory-sync/[directoryId]/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
}
Expand Down
4 changes: 2 additions & 2 deletions pages/api/setup/[token]/directory-sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
}
Expand Down
4 changes: 2 additions & 2 deletions pages/api/setup/[token]/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
}
Expand Down
4 changes: 2 additions & 2 deletions pages/api/setup/[token]/sso-connection/[id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
}
Expand Down
4 changes: 2 additions & 2 deletions pages/api/setup/[token]/sso-connection/idp-entityid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
}
Expand Down
2 changes: 1 addition & 1 deletion pages/setup/[token]/sso-connection/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down

0 comments on commit 454d52a

Please sign in to comment.