pages/api/trpc: track only server errors
This commit is contained in:
parent
4dd4038091
commit
1d9c35b953
@ -23,16 +23,17 @@ export default trpcNext.createNextApiHandler({
|
||||
onError(opts) {
|
||||
const { error } = opts;
|
||||
// send to bug reporting
|
||||
withScope((scope) => {
|
||||
(Object.keys(opts) as Array<keyof typeof opts>).forEach((key) => {
|
||||
if (key !== 'req') {
|
||||
let extra = opts[key];
|
||||
if (key === 'input') extra = JSON.stringify(extra);
|
||||
scope.setExtra(key, extra);
|
||||
}
|
||||
if (!['BAD_REQUEST', 'UNAUTHORIZED', 'FORBIDDEN'].includes(error.code))
|
||||
withScope((scope) => {
|
||||
(Object.keys(opts) as Array<keyof typeof opts>).forEach((key) => {
|
||||
if (key !== 'req') {
|
||||
let extra = opts[key];
|
||||
if (key === 'input') extra = JSON.stringify(extra);
|
||||
scope.setExtra(key, extra);
|
||||
}
|
||||
});
|
||||
captureException(error);
|
||||
});
|
||||
captureException(error);
|
||||
});
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Something went wrong', error);
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user