summaryrefslogtreecommitdiffhomepage
path: root/packages/browser/src/helpers/__jest__/generateCustomError.ts
blob: f4b325042ce9b8953229e6151242d482b9fc9be4 (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;
}