-
Notifications
You must be signed in to change notification settings - Fork 55
/
errors.ts
53 lines (47 loc) · 1.44 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const nonCriticalErrorCodes = ['NO_TESTS_TO_RUN', 'MISSING_TESTS'] as const
export type NonCriticalCiErrorCode = typeof nonCriticalErrorCodes[number]
const criticalErrorCodes = [
'AUTHORIZATION_ERROR',
'INVALID_CONFIG',
'MISSING_API_KEY',
'MISSING_APP_KEY',
'POLL_RESULTS_FAILED',
'BATCH_TIMEOUT_RUNAWAY',
'TOO_MANY_TESTS_TO_TRIGGER',
'TRIGGER_TESTS_FAILED',
'TUNNEL_START_FAILED',
'TUNNEL_NOT_SUPPORTED',
'UNAVAILABLE_TEST_CONFIG',
'UNAVAILABLE_TUNNEL_CONFIG',
'UPLOAD_MOBILE_APPLICATION_TESTS_FAILED',
'MISSING_MOBILE_APPLICATION_PATH',
'MISSING_MOBILE_APPLICATION_ID',
'MISSING_MOBILE_VERSION_NAME',
'INVALID_MOBILE_APP',
'INVALID_MOBILE_APP_UPLOAD_PARAMETERS',
'MOBILE_APP_UPLOAD_TIMEOUT',
'UNKNOWN_MOBILE_APP_UPLOAD_FAILURE',
] as const
export type CriticalCiErrorCode = typeof criticalErrorCodes[number]
export type CiErrorCode = NonCriticalCiErrorCode | CriticalCiErrorCode
export class CiError extends Error {
constructor(public code: CiErrorCode, message?: string) {
super(message)
}
public toJson() {
return {
code: this.code,
message: this.message,
}
}
}
export class CriticalError extends CiError {
constructor(public code: CriticalCiErrorCode, message?: string) {
super(code, message)
}
}
export class BatchTimeoutRunawayError extends CriticalError {
constructor() {
super('BATCH_TIMEOUT_RUNAWAY', "The batch didn't timeout after the expected timeout period.")
}
}