Skip to content

Commit

Permalink
feat: update error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
yasinatesim committed Jul 12, 2023
1 parent fdd9897 commit e0d456a
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions pages/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,11 @@ async function Index(req: NextApiRequest, res: NextApiResponse<ErrorResponse | {
} catch (error) {
const errorMessage = error instanceof Error ? error.message : 'Something went wrong';

if (error instanceof IgLoginRequiredError) {
await fakeDelete();

return res.status(400).json({
status: 'Failed',
message: 'Session expired, please try again',
});
}

if (errorMessage.includes('few minutes before')) {
/**
* login_required error
* "Please wait a few minutes before you try again." error
*/
if (error instanceof IgLoginRequiredError || errorMessage.includes('few minutes before')) {
await fakeDelete();

return res.status(400).json({
Expand Down

1 comment on commit e0d456a

@vercel
Copy link

@vercel vercel bot commented on e0d456a Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.