-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiResponses.ts
57 lines (49 loc) · 1.2 KB
/
apiResponses.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
54
55
56
57
import { Slices } from "./slices"
// Different classes representing possible Api Response outcomes
class JsonParseError {
msg: string
constructor(msg: string) {
this.msg = msg
}
}
class ApiHttpError {
code: number
msg: string
headers: string
constructor(code: number, msg: string, headers: string) {
this.code = code
this.msg = msg
this.headers = headers
}
}
class CompilerError {
msg: string
errortype: string
constructor(msg: string, errortype: string) {
this.msg = msg
this.errortype = errortype
}
}
class CompilationResultSuccess {
slices: Slices
compilation_text: string
constructor(slices: Slices, compilation_text: string) {
this.slices = slices
this.compilation_text = compilation_text
}
}
class NoServerResponse {
response: string
constructor(response: string) {
this.response = response
}
}
type ApiResponse =
| null
| JsonParseError
| ApiHttpError
| CompilationResultSuccess
| CompilerError
| NoServerResponse
export type { ApiResponse }
export { JsonParseError, ApiHttpError, CompilationResultSuccess, NoServerResponse, CompilerError }