cue: remove uses of log.Panicf

Fixes #174.

Change-Id: I4858443a8e347add551405c59332f3bcdb4a60c1
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/4021
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/build/import.go b/cue/build/import.go
index 3f255f3..f8eea93 100644
--- a/cue/build/import.go
+++ b/cue/build/import.go
@@ -15,7 +15,6 @@
 package build
 
 import (
-	"log"
 	"sort"
 	"strconv"
 
@@ -64,8 +63,11 @@
 				quoted := spec.Path.Value
 				path, err := strconv.Unquote(quoted)
 				if err != nil {
-					// TODO: remove panic
-					log.Panicf("%s: parser returned invalid quoted string: <%s>", f.Filename, quoted)
+					inst.Err = errors.Append(inst.Err,
+						errors.Newf(
+							spec.Path.Pos(),
+							"%s: parser returned invalid quoted string: <%s>",
+							f.Filename, quoted))
 				}
 				imported[path] = append(imported[path], spec.Pos())
 			}
diff --git a/cue/load/import.go b/cue/load/import.go
index 9fe0ca0..4adbade 100644
--- a/cue/load/import.go
+++ b/cue/load/import.go
@@ -16,7 +16,6 @@
 
 import (
 	"bytes"
-	"log"
 	"os"
 	"path/filepath"
 	"sort"
@@ -396,7 +395,10 @@
 			quoted := spec.Path.Value
 			path, err := strconv.Unquote(quoted)
 			if err != nil {
-				log.Panicf("%s: parser returned invalid quoted string: <%s>", filename, quoted)
+				badFile(errors.Newf(
+					spec.Path.Pos(),
+					"%s: parser returned invalid quoted string: <%s>", filename, quoted,
+				))
 			}
 			if !isTest || fp.c.Tests {
 				fp.imported[path] = append(fp.imported[path], spec.Pos())