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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | 1x 1x 1x 1x 3x 3x 5x 5x 5x 1x 1x 3x | /** * Something was wrong while building URL for identification request * * @group Errors */ export class InvalidUrlError extends Error { constructor(message: string) { super(message) this.name = 'InvalidURL' } } /** * Something was wrong with params while building URL for identification request * * @group Errors */ export class InvalidURLParamsError extends Error { constructor(message: string) { super(message) this.name = 'InvalidURLParams' } } /** * Unknown API error * * @group Errors */ export class ApiError extends Error { constructor(message: string) { super(message) this.name = 'ApiError' } } /** * Token is missing in the request * * @group Errors */ export class ApiKeyRequiredError extends Error { constructor(message: string) { super(message) this.name = 'ApiKeyRequiredError' } } /** * Wrong token * * @group Errors */ export class ApiKeyNotFoundError extends Error { constructor(message: string) { super(message) this.name = 'ApiKeyNotFoundError' } } /** * API token is outdated * * @group Errors */ export class ApiKeyExpiredError extends Error { constructor(message: string) { super(message) this.name = 'ApiKeyExpiredError' } } /** * Wrong request format (content, parameters) * * @group Errors */ export class RequestCannotBeParsedError extends Error { constructor(message: string) { super(message) this.name = 'RequestCannotBeParsedError' } } /** * Request failed * * @group Errors */ export class FailedError extends Error { constructor(message: string) { super(message) this.name = 'FailedError' } } /** * Server timeout * * @group Errors */ export class RequestTimeoutError extends Error { constructor(message: string) { super(message) this.name = 'RequestTimeoutError' } } /** * Request limit for token reached * * @group Errors */ export class TooManyRequestError extends Error { constructor(message: string) { super(message) this.name = 'TooManyRequestError' } } /** * Request Filtering deny origin * * @group Errors */ export class OriginNotAvailableError extends Error { constructor(message: string) { super(message) this.name = 'OriginNotAvailableError' } } /** * Request Filtering deny some headers * * @group Errors */ export class HeaderRestrictedError extends Error { constructor(message: string) { super(message) this.name = 'HeaderRestrictedError' } } /** * Request Filtering deny this hostname * * @group Errors */ export class HostnameRestrictedError extends Error { constructor(message: string) { super(message) this.name = 'HostnameRestrictedError' } } /** * Request Filtering deny crawlers * * @group Errors */ export class NotAvailableForCrawlBotsError extends Error { constructor(message: string) { super(message) this.name = 'NotAvailableForCrawlBotsError' } } /** * Request Filtering deny empty UA * * @group Errors */ export class NotAvailableWithoutUAError extends Error { constructor(message: string) { super(message) this.name = 'NotAvailableWithoutUAError' } } /** * API key does not match the selected region * * @group Errors */ export class WrongRegionError extends Error { constructor(message: string) { super(message) this.name = 'WrongRegionError' } } /** * Subscription is not active for the provided API key * * @group Errors */ export class SubscriptionNotActiveError extends Error { constructor(message: string) { super(message) this.name = 'SubscriptionNotActiveError' } } /** * Something wrong with used API version * * @group Errors */ export class UnsupportedVersionError extends Error { constructor(message: string) { super(message) this.name = 'UnsupportedVersionError' } } /** * * * @group Errors */ export class InstallationMethodRestrictedError extends Error { constructor(message: string) { super(message) this.name = 'InstallationMethodRestrictedError' } } /** * Error while parsing the response * * @group Errors */ export class ResponseCannotBeParsedError extends Error { constructor(message: string) { super(message) this.name = 'ResponseCannotBeParsedError' } } /** * Something wrong with network * * @group Errors */ export class NetworkError extends Error { constructor(message: string) { super(message) this.name = 'NetworkError' } } /** * Error while parsing JSON response * * @group Errors */ export class JsonParsingError extends Error { constructor(message: string) { super(message) this.name = 'JsonParsingError' } } /** * Bad response type * * @group Errors */ export class InvalidResponseTypeError extends Error { constructor(message: string) { super(message) this.name = 'InvalidResponseType' } } /** * Other error * * @group Errors */ export class UnknownError extends Error { constructor(message: string) { super(message) this.name = 'UnknownError' } } export type IdentificationError = | InvalidUrlError | InvalidURLParamsError | ApiError | ApiKeyRequiredError | ApiKeyNotFoundError | ApiKeyExpiredError | RequestCannotBeParsedError | FailedError | RequestTimeoutError | TooManyRequestError | OriginNotAvailableError | HeaderRestrictedError | NotAvailableForCrawlBotsError | NotAvailableWithoutUAError | WrongRegionError | SubscriptionNotActiveError | UnsupportedVersionError | InstallationMethodRestrictedError | ResponseCannotBeParsedError | NetworkError | JsonParsingError | InvalidResponseTypeError | UnknownError export function unwrapError(error: Error): IdentificationError { const [errorType, ...errorMessageParts] = error.message.split(':') const errorMessage = errorMessageParts.join(':') switch (errorType) { case 'InvalidURL': return new InvalidUrlError(errorMessage) case 'InvalidURLParams': return new InvalidURLParamsError(errorMessage) case 'ApiError': return new ApiError(errorMessage) // Api Errors block case 'ApiKeyRequired': case 'TokenRequired': return new ApiKeyRequiredError(errorMessage) case 'ApiKeyNotFound': case 'TokenNotFound': return new ApiKeyNotFoundError(errorMessage) case 'ApiKeyExpired': case 'TokenExpired': return new ApiKeyExpiredError(errorMessage) case 'RequestCannotBeParsed': return new RequestCannotBeParsedError(errorMessage) case 'Failed': return new FailedError(errorMessage) case 'RequestTimeout': return new RequestTimeoutError(errorMessage) case 'TooManyRequest': return new TooManyRequestError(errorMessage) case 'OriginNotAvailable': return new OriginNotAvailableError(errorMessage) case 'HeaderRestricted': return new HeaderRestrictedError(errorMessage) case 'HostnameRestricted': return new HostnameRestrictedError(errorMessage) case 'NotAvailableForCrawlBots': return new NotAvailableForCrawlBotsError(errorMessage) case 'NotAvailableWithoutUA': return new NotAvailableWithoutUAError(errorMessage) case 'WrongRegion': return new WrongRegionError(errorMessage) case 'SubscriptionNotActive': return new SubscriptionNotActiveError(errorMessage) case 'UnsupportedVersion': return new UnsupportedVersionError(errorMessage) case 'InstallationMethodRestricted': return new InstallationMethodRestrictedError(errorMessage) case 'ResponseCannotBeParsed': return new ResponseCannotBeParsedError(errorMessage) // end of API Errors block case 'NetworkError': return new NetworkError(errorMessage) case 'JsonParsingError': return new JsonParsingError(errorMessage) case 'InvalidResponseType': return new InvalidResponseTypeError(errorMessage) default: return new UnknownError(error.message) } } |