Skip to content

Commit

Permalink
Add more context when script options can't be parsed
Browse files Browse the repository at this point in the history
This only makes certain the error does actually specify it is about the
options.

Updates #2909
  • Loading branch information
mstoykov committed Feb 10, 2023
1 parent a78916c commit a37aec3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (b *Bundle) getExports(logger logrus.FieldLogger, rt *goja.Runtime, updateO
}
data, err := json.Marshal(v.Export())
if err != nil {
return err
return fmt.Errorf("error parsing script options: %w", err)
}
dec := json.NewDecoder(bytes.NewReader(data))
dec.DisallowUnknownFields()
Expand Down
2 changes: 1 addition & 1 deletion js/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func TestNewBundle(t *testing.T) {
Expr, Error string
}{
"Array": {`[]`, "json: cannot unmarshal array into Go value of type lib.Options"},
"Function": {`function(){}`, "json: unsupported type: func(goja.FunctionCall) goja.Value"},
"Function": {`function(){}`, "error parsing script options: json: unsupported type: func(goja.FunctionCall) goja.Value"},
}
for name, data := range invalidOptions {
t.Run(name, func(t *testing.T) {
Expand Down

0 comments on commit a37aec3

Please sign in to comment.