miller/internal/pkg/dsl/token.go
John Kerl d03ef16cfc
Add line/column info for DSL runtime non-parse failures (#998)
* Add line/column info for DSL runtime non-parse failures

* Other related callsites

* test cases

* Update already-existing test cases
2022-03-20 21:57:11 -04:00

17 lines
465 B
Go

package dsl
import (
"fmt"
"github.com/johnkerl/miller/internal/pkg/parsing/token"
)
// TokenToLocationInfo is used to track runtime errors back to source-code locations in DSL
// expressions, so we can have more informative error messages.
func TokenToLocationInfo(sourceToken *token.Token) string {
if sourceToken == nil {
return ""
} else {
return fmt.Sprintf(" at DSL expression line %d column %d", sourceToken.Pos.Line, sourceToken.Pos.Column)
}
}