internal/protobuf: record position information

for both errors and in the AST.

Removes the error type, which now implements the
standard CUE error conventions.

Change-Id: I7a4198a9cf9b38622f14f63df827f3f9730fe4b5
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2341
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/internal/protobuf/util.go b/internal/protobuf/util.go
index 980a7d3..d1040d0 100644
--- a/internal/protobuf/util.go
+++ b/internal/protobuf/util.go
@@ -16,6 +16,7 @@
 
 import (
 	"strings"
+	"text/scanner"
 
 	"cuelang.org/go/cue/ast"
 	"cuelang.org/go/cue/token"
@@ -25,15 +26,16 @@
 
 // failf panics with a marked error that can be intercepted upon returning
 // from parsing.
-func failf(format string, args ...interface{}) {
-	panic(protoError{xerrors.Errorf(format, args...)})
+func failf(pos scanner.Position, format string, args ...interface{}) {
+	panic(protoError{pos, xerrors.Errorf(format, args...)})
 }
 
-func fail(err error) {
-	panic(protoError{err})
+func fail(pos scanner.Position, err error) {
+	panic(protoError{pos, err})
 }
 
 type protoError struct {
+	pos scanner.Position
 	error
 }