-
Notifications
You must be signed in to change notification settings - Fork 554
/
errors.ts
36 lines (32 loc) · 1.06 KB
/
errors.ts
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
/**
* Errors of `NonRetryableError` type will never be retried by the crawler.
*/
export class NonRetryableError extends Error {}
/**
* Errors of `CriticalError` type will shut down the whole crawler.
*/
export class CriticalError extends NonRetryableError {}
/**
* @ignore
*/
export class MissingRouteError extends CriticalError {}
/**
* Errors of `RetryRequestError` type will always be retried by the crawler.
*
* *This error overrides the `maxRequestRetries` option, i.e. the request can be retried indefinitely until it succeeds.*
*/
export class RetryRequestError extends Error {
constructor(message?: string) {
super(message ?? "Request is being retried at the user's request");
}
}
/**
* Errors of `SessionError` type will trigger a session rotation.
*
* This error doesn't respect the `maxRequestRetries` option and has a separate limit of `maxSessionRotations`.
*/
export class SessionError extends RetryRequestError {
constructor(message?: string) {
super(message ?? 'Detected a session error, rotating session...');
}
}