Skip to content

Commit

Permalink
add name to custom errors, remove debounce for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmkm committed Jul 11, 2023
1 parent db334b9 commit d5238c6
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions src/lib/utils/errors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { captureException } from '@sentry/browser';
import { ScopeContext } from '@sentry/types/types/scope';
import debounce from 'lodash/debounce';

type BalancerExceptionAction = 'swap' | 'joinPool' | 'exitPool';

Expand All @@ -17,20 +16,18 @@ export function captureBalancerException(
tags.balError = balError;
}

debounce(() => {
captureException(
getErrorForAction(action, `${messagePrefix}: ${reason}`, error),
{
...captureContext,
extra: {
...captureContext?.extra,
reason,
balError,
},
tags,
}
);
}, 1000);
captureException(
getErrorForAction(action, `${messagePrefix}: ${reason}`, error),
{
...captureContext,
extra: {
...captureContext?.extra,
reason,
balError,
},
tags,
}
);
}

function getReasonAndBalErrorFromError(error: Error): {
Expand All @@ -54,14 +51,20 @@ function getErrorForAction(
) {
switch (action) {
case 'swap':
return new SwapError(message, { cause: originalError });
return new BatchSwapError(message, { cause: originalError });
case 'joinPool':
return new JoinPoolError(message, { cause: originalError });
case 'exitPool':
return new ExitPoolError(message, { cause: originalError });
}
}

class SwapError extends Error {}
class JoinPoolError extends Error {}
class ExitPoolError extends Error {}
class BatchSwapError extends Error {
name = 'BatchSwapError';
}
class JoinPoolError extends Error {
name = 'JoinPoolError';
}
class ExitPoolError extends Error {
name = 'ExitPoolError';
}

0 comments on commit d5238c6

Please sign in to comment.