utils/axios: extend error.exception message

This commit is contained in:
vchikalkin 2023-07-11 22:13:29 +03:00
parent a9589f09e5
commit 0ea8c23c81

View File

@ -24,13 +24,15 @@ export async function withHandleError<T>(fn: Promise<T>) {
const message = getErrorMessage(error_);
const opts = { ...err, data, message, params };
error_.message += ` | ${message}`;
withScope((scope) => {
(Object.keys(opts) as Array<keyof typeof opts>).forEach((key) => {
let extra = opts[key];
if (key === 'data') extra = JSON.stringify(extra);
scope.setExtra(key, extra);
});
captureException(`${error_.message} | ${message}`);
captureException(error_);
});
throw new Error(message);