9942 commits 0 issues 0 pull requests 439 contributors 0 branches 0 releases
Additions: 7 Deletions: 0
vlib/builtin/option.v
1 return 'none'
2 }
3
4+[if trace_error]
5+fn trace_error(x string) {
6+ eprintln('> ${@FN} | $x')
7+}
8+
9 // error returns a default error instance containing the error given in `message`.
10 // Example: `if ouch { return error('an error occurred') }`
11 [inline]
12 pub fn error(message string) IError {
13+ trace_error(message)
14 return &Error{
15 msg: message
16 }
17 // `if ouch { return error_with_code('an error occurred', 1) }`
18 [inline]
19 pub fn error_with_code(message string, code int) IError {
20+ trace_error('$message | code: $code')
21 return &Error{
22 msg: message
23 code: code
24