-
Notifications
You must be signed in to change notification settings - Fork 1
/
errors.v
111 lines (92 loc) · 1.63 KB
/
errors.v
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
module gura
pub struct ParseError {
Error
pub:
msg string
line int
pos int
}
fn new_parse_error(pos int, line int, msg string) IError {
return &ParseError{
pos: pos
line: line
msg: msg
}
}
pub fn (err &ParseError) msg() string {
return '$err.msg at line $err.line position $err.pos'
}
fn check_parse_error(err IError) ?RuleResult {
if err is ParseError {
return none
}
// if it is not a ParseError, return it to stop parsing
return err
}
pub struct DuplicatedImportError {
Error
pub:
msg string
}
fn new_duplicated_variable_error(msg string) IError {
return &DuplicatedImportError{
msg: msg
}
}
pub fn (err &DuplicatedImportError) msg() string {
return err.msg
}
pub struct DuplicatedVariableError {
Error
pub:
msg string
}
fn new_duplicated_import_error(msg string) IError {
return &DuplicatedVariableError{
msg: msg
}
}
pub fn (err &DuplicatedVariableError) msg() string {
return err.msg
}
pub struct FileNotFoundError {
Error
pub:
msg string
}
fn new_file_not_found_error(msg string) IError {
return &FileNotFoundError{
msg: msg
}
}
pub fn (err &FileNotFoundError) msg() string {
return err.msg
}
pub struct InvalidIndentationError {
Error
pub:
msg string
}
fn new_invalid_indentation_error(msg string) IError {
return &InvalidIndentationError{
msg: msg
}
}
pub fn (err &InvalidIndentationError) msg() string {
return err.msg
}
pub struct VariableNotDefinedError {
Error
pub:
key string
msg string
}
fn new_variable_not_defined_error(key string, msg string) IError {
return &VariableNotDefinedError{
key: key
msg: msg
}
}
pub fn (err &VariableNotDefinedError) msg() string {
return err.msg
}