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) {
|
onError(opts) {
|
||||||
const { error } = opts;
|
const { error } = opts;
|
||||||
// send to bug reporting
|
// send to bug reporting
|
||||||
withScope((scope) => {
|
if (!['BAD_REQUEST', 'UNAUTHORIZED', 'FORBIDDEN'].includes(error.code))
|
||||||
(Object.keys(opts) as Array<keyof typeof opts>).forEach((key) => {
|
withScope((scope) => {
|
||||||
if (key !== 'req') {
|
(Object.keys(opts) as Array<keyof typeof opts>).forEach((key) => {
|
||||||
let extra = opts[key];
|
if (key !== 'req') {
|
||||||
if (key === 'input') extra = JSON.stringify(extra);
|
let extra = opts[key];
|
||||||
scope.setExtra(key, extra);
|
if (key === 'input') extra = JSON.stringify(extra);
|
||||||
}
|
scope.setExtra(key, extra);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
captureException(error);
|
||||||
});
|
});
|
||||||
captureException(error);
|
|
||||||
});
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error('Something went wrong', error);
|
console.error('Something went wrong', error);
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user