forked from nginxinc/nginx-go-crossplane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
43 lines (37 loc) · 840 Bytes
/
errors.go
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
/**
* Copyright (c) F5, Inc.
*
* This source code is licensed under the Apache License, Version 2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
package crossplane
import (
"encoding/json"
"fmt"
)
type ParseError struct {
What string
File *string
Line *int
// Raw directive statement causing the parse error.
Statement string
// Block in which parse error occurred.
BlockCtx string
originalErr error
}
func (e *ParseError) Error() string {
file := "(nofile)"
if e.File != nil {
file = *e.File
}
if e.Line != nil {
return fmt.Sprintf("%s in %s:%d", e.What, file, *e.Line)
}
return fmt.Sprintf("%s in %s", e.What, file)
}
func (e *ParseError) MarshalJSON() ([]byte, error) {
return json.Marshal(e.Error())
}
func (e *ParseError) Unwrap() error {
return e.originalErr
}