node/error: handle the case where no position is available for inner node
This commit is contained in:
parent
75b13e0842
commit
8986937340
7
node.go
7
node.go
@ -26,7 +26,12 @@ type parseErr struct {
|
||||
}
|
||||
|
||||
func (pe parseErr) Error() string {
|
||||
return fmt.Sprintf("Parsing %s on line %d: %s", nodeTypeString(pe.n), pe.n.GetPosition().StartLine, pe.childErr)
|
||||
positionStr := ""
|
||||
if posn := pe.n.GetPosition(); posn != nil {
|
||||
positionStr = fmt.Sprintf(" on line %d", posn.StartLine)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("Parsing %s%s: %s", nodeTypeString(pe.n), positionStr, pe.childErr.Error())
|
||||
}
|
||||
|
||||
func (pe parseErr) Unwrap() error {
|
||||
|
Loading…
Reference in New Issue
Block a user