forked from gb3h/ocaml-type-inference-in-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.ts
37 lines (33 loc) · 769 Bytes
/
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
/* tslint:disable:max-classes-per-file */
enum ErrorType {
PARSE,
INFERENCE,
UNIFICATION,
}
export class AstError {
constructor(public explanation: string) {}
public explain() {
return this.explanation
}
toString() {
return this.explain()
}
}
export class ParseError extends AstError {
public errorType = ErrorType.PARSE
toString() {
return "Parse Error: " + super.toString()
}
}
export class InferenceError extends AstError {
public errorType = ErrorType.INFERENCE
toString() {
return "Inference Error: " + super.toString()
}
}
export class UnificationError extends AstError {
public errorType = ErrorType.UNIFICATION
toString() {
return "Unification Error: " + super.toString()
}
}