Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | import {
ApiKeyExpiredError,
ApiKeyNotFoundError,
ApiKeyRequiredError,
ClientTimeoutError,
FailedError,
HeaderRestrictedError,
HostnameRestrictedError,
IdentificationError,
InstallationMethodRestrictedError,
InvalidProxyIntegrationHeadersError,
InvalidProxyIntegrationSecretError,
NetworkError,
OriginNotAvailableError,
ProxyIntegrationSecretEnvironmentMismatch,
RequestCannotBeParsedError,
RequestTimeoutError,
ResponseCannotBeParsedError,
SubscriptionNotActiveError,
TooManyRequestError,
UnknownError,
UnsupportedVersionError,
WrongRegionError,
} from './errors'
import { FingerprintJSPro } from '@fingerprintjs/fingerprintjs-pro-spa'
/**
* Web implementation for error handling. Note: not all errors from native SDK are available on the web.
*
* @platform web
* */
export function unwrapError(error: Error): IdentificationError {
switch (error.message) {
// Api Errors block
case FingerprintJSPro.ERROR_API_KEY_MISSING:
return new ApiKeyRequiredError(error.message)
case FingerprintJSPro.ERROR_API_KEY_INVALID:
return new ApiKeyNotFoundError(error.message)
case FingerprintJSPro.ERROR_API_KEY_EXPIRED:
return new ApiKeyExpiredError(error.message)
case FingerprintJSPro.ERROR_BAD_REQUEST_FORMAT:
return new RequestCannotBeParsedError(error.message)
case FingerprintJSPro.ERROR_GENERAL_SERVER_FAILURE:
return new FailedError(error.message)
case FingerprintJSPro.ERROR_SERVER_TIMEOUT:
return new RequestTimeoutError(error.message)
case FingerprintJSPro.ERROR_RATE_LIMIT:
return new TooManyRequestError(error.message)
case FingerprintJSPro.ERROR_FORBIDDEN_ORIGIN:
return new OriginNotAvailableError(error.message)
case FingerprintJSPro.ERROR_FORBIDDEN_HEADER:
return new HeaderRestrictedError(error.message)
case FingerprintJSPro.ERROR_FORBIDDEN_ENDPOINT:
return new HostnameRestrictedError(error.message)
case FingerprintJSPro.ERROR_WRONG_REGION:
return new WrongRegionError(error.message)
case FingerprintJSPro.ERROR_SUBSCRIPTION_NOT_ACTIVE:
return new SubscriptionNotActiveError(error.message)
case FingerprintJSPro.ERROR_UNSUPPORTED_VERSION:
return new UnsupportedVersionError(error.message)
case FingerprintJSPro.ERROR_INSTALLATION_METHOD_RESTRICTED:
return new InstallationMethodRestrictedError(error.message)
case FingerprintJSPro.ERROR_BAD_RESPONSE_FORMAT:
return new ResponseCannotBeParsedError(error.message)
// end of API Errors block
case FingerprintJSPro.ERROR_CLIENT_TIMEOUT:
return new ClientTimeoutError(error.message)
case FingerprintJSPro.ERROR_NETWORK_CONNECTION:
case FingerprintJSPro.ERROR_NETWORK_ABORT:
case FingerprintJSPro.ERROR_NETWORK_RESTRICTED:
return new NetworkError(error.message)
case FingerprintJSPro.ERROR_INVALID_PROXY_INTEGRATION_HEADERS:
return new InvalidProxyIntegrationHeadersError(error.message)
case FingerprintJSPro.ERROR_PROXY_INTEGRATION_SECRET_ENVIRONMENT_MISMATCH:
return new ProxyIntegrationSecretEnvironmentMismatch(error.message)
case FingerprintJSPro.ERROR_INVALID_PROXY_INTEGRATION_SECRET:
return new InvalidProxyIntegrationSecretError(error.message)
default:
return new UnknownError(error.message)
}
}
|