Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
cue: remove uses of log.Panicf
Browse files Browse the repository at this point in the history
Fixes #174.

Change-Id: I4858443a8e347add551405c59332f3bcdb4a60c1
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/4021
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Nov 16, 2019
1 parent 31cd2b7 commit 030b9b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions cue/build/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package build

import (
"log"
"sort"
"strconv"

Expand Down Expand Up @@ -64,8 +63,11 @@ func (inst *Instance) complete() errors.Error {
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())
}
Expand Down
6 changes: 4 additions & 2 deletions cue/load/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package load

import (
"bytes"
"log"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -396,7 +395,10 @@ func (fp *fileProcessor) add(pos token.Pos, root, path string, mode importMode)
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())
Expand Down

0 comments on commit 030b9b7

Please sign in to comment.