summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/helpers/__jest__/generateCustomError.ts
blob: 7c018ca68da21117c097708bb24f10c440d0537a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * Create "custom errors" to help emulate WebAuthn API errors
 */
type WebAuthnErrorName =
  | 'AbortError'
  | 'ConstraintError'
  | 'InvalidStateError'
  | 'NotAllowedError'
  | 'NotSupportedError'
  | 'SecurityError'
  | 'UnknownError';

export function generateCustomError(name: WebAuthnErrorName): Error {
  const customError = new Error();
  customError.name = name;
  return customError;
}