Skip to content

Commit

Permalink
Apply formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jackson-amplitude authored and github-actions[bot] committed Jun 6, 2024
1 parent 510bd8f commit ec2e864
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/rrweb/src/record/error-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ErrorHandler } from '../types';

type Callback = (...args: unknown[]) => unknown;
type GenericFunction = (...args: any[]) => any;
type ExternalError = Error & {_external_: boolean}
type ExternalError = Error & { _external_: boolean };

let errorHandler: ErrorHandler | undefined;

Expand Down Expand Up @@ -37,17 +37,19 @@ export const callbackWrapper = <T extends Callback>(cb: T): T => {
return rrwebWrapped;
};

export function externalFunctionWrapper<T extends GenericFunction>(func: T): (...args: Parameters<T>) => ReturnType<T> {
export function externalFunctionWrapper<T extends GenericFunction>(
func: T,
): (...args: Parameters<T>) => ReturnType<T> {
return (...args: Parameters<T>) => {
try {
return func(...args);
} catch (error) {
try {
(error as ExternalError)._external_ = true;
} catch {
// in case we can't assign, don't do anything.
}
throw error
try {
(error as ExternalError)._external_ = true;
} catch {
// in case we can't assign, don't do anything.
}
throw error;
}
};
}
}

0 comments on commit ec2e864

Please sign in to comment.