chore: suppress sentry logs when eth fails - fix lint and unit tests

This commit is contained in:
maciek
2023-05-11 15:59:21 +02:00
parent 3c5240fe21
commit fa616623bc
10 changed files with 19 additions and 12 deletions
@@ -63,7 +63,7 @@ export const useDepositBalances = (
});
} catch (err) {
const logger = localLoggerFactory({ application: 'deposits' });
if (err.message.match(/call revert exception/)) {
if ((err as Error).message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
+1 -1
View File
@@ -26,7 +26,7 @@ export const useGetAllowance = (
return new BigNumber(addDecimal(res.toString(), asset.decimals));
} catch (err) {
const logger = localLoggerFactory({ application: 'deposits' });
if (err.message.match(/call revert exception/)) {
if ((err as Error).message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
@@ -20,7 +20,7 @@ export const useGetDepositMaximum = (
return max.isEqualTo(0) ? new BigNumber(Infinity) : max;
} catch (err) {
const logger = localLoggerFactory({ application: 'deposits' });
if (err.message.match(/call revert exception/)) {
if ((err as Error).message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
@@ -41,7 +41,7 @@ export const useGetDepositedAmount = (asset: Asset | undefined) => {
return new BigNumber(addDecimal(value, asset.decimals));
} catch (err) {
const logger = localLoggerFactory({ application: 'deposits' });
if (err.message.match(/call revert exception/)) {
if ((err as Error).message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
+1 -1
View File
@@ -1,4 +1,4 @@
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';
import type { Severity } from '@sentry/types/types/severity';
import { LocalLogger, localLoggerFactory } from './local-logger';
+10 -3
View File
@@ -1,4 +1,4 @@
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/react';
import type { Scope } from '@sentry/browser';
import type { Severity, Breadcrumb, Primitive } from '@sentry/types';
@@ -13,7 +13,14 @@ const LogLevels = [
'silent',
];
type LogLevelsType = typeof LogLevels[number];
type ConsoleArg = string | number | boolean | bigint | symbol | object;
type ConsoleArg =
| string
| number
| boolean
| bigint
| symbol
| object
| unknown;
type ConsoleMethod = {
[K in keyof Console]: Console[K] extends (...args: ConsoleArg[]) => unknown
? K
@@ -110,7 +117,7 @@ export class LocalLogger {
if (this.tags.length) {
this.tags.forEach((tag) => {
const found = args.reduce((aggr, arg) => {
if (typeof arg === 'object' && tag in arg) {
if (arg && typeof arg === 'object' && tag in arg) {
// @ts-ignore change object to record
aggr = arg[tag] as unknown as Primitive | object;
}
+1 -1
View File
@@ -14,7 +14,7 @@ export const useGetWithdrawDelay = () => {
return res.toNumber();
} catch (err) {
const logger = localLoggerFactory({ application: 'web3' });
if (err.message.match(/call revert exception/)) {
if ((err as Error).message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
@@ -56,7 +56,7 @@ export const useCompleteWithdraw = () => {
);
} catch (err) {
const logger = localLoggerFactory({ application: 'deposits' });
if (err.message.match(/call revert exception/)) {
if ((err as Error).message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
@@ -120,7 +120,7 @@ export const useVerifyWithdrawal = () => {
return true;
} catch (err) {
const logger = localLoggerFactory({ application: 'withdraws' });
if (err.message.match(/call revert exception/)) {
if ((err as Error).message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);
@@ -47,7 +47,7 @@ export const useWithdrawAsset = (
delay = result[1];
} catch (err) {
const logger = localLoggerFactory({ application: 'withdraws' });
if (err.message.match(/call revert exception/)) {
if ((err as Error).message.match(/call revert exception/)) {
logger.info('call revert eth exception', err);
} else {
logger.error(err);