Skip to content

Commit

Permalink
Handle error
Browse files Browse the repository at this point in the history
  • Loading branch information
niwsa committed Nov 27, 2023
1 parent 9afca05 commit a0116a0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion pages/api/oauth/authorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export default async function handler(
});
}
} catch (err: any) {
res.status(500).json({ error: { message: err.message } });
const message = err.message || 'Something went wrong';
const status = err.status || 500;
res.status(status).json({ error: { message } });
}
}

Expand Down
6 changes: 4 additions & 2 deletions pages/api/oauth/saml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ export default async function handler(
});
}
} catch (err: any) {
// TODO: Handle error
console.error('saml error:', err);
const message = err.message || 'Something went wrong';
const status = err.status || 500;

res.status(status).json({ error: { message } });
}
}

Expand Down
6 changes: 4 additions & 2 deletions pages/api/oauth/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ export default async function handler(
});
}
} catch (err: any) {
// TODO: Handle error
console.error('token error:', err);
const message = err.message || 'Something went wrong';
const status = err.status || 500;

res.status(status).json({ error: { message } });
}
}

Expand Down

0 comments on commit a0116a0

Please sign in to comment.