Skip to content

Commit

Permalink
Update go.mod
Browse files Browse the repository at this point in the history
  • Loading branch information
hattya committed Dec 25, 2023
1 parent e639e1d commit 8438061
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/hattya/otto.module

go 1.19

require github.com/robertkrimen/otto v0.2.1
require github.com/robertkrimen/otto v0.3.0

require (
golang.org/x/text v0.4.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/robertkrimen/otto v0.2.1 h1:FVP0PJ0AHIjC+N4pKCG9yCDz6LHNPCwi/GKID5pGGF0=
github.com/robertkrimen/otto v0.2.1/go.mod h1:UPwtJ1Xu7JrLcZjNWN8orJaM5n5YEtqL//farB5FlRY=
github.com/robertkrimen/otto v0.3.0 h1:5RI+8860NSxvXywDY9ddF5HcPw0puRsd8EgbXV0oqRE=
github.com/robertkrimen/otto v0.3.0/go.mod h1:uW9yN1CYflmUQYvAMS0m+ZiNo3dMzRUDQJX0jWbzgxw=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
Expand Down
20 changes: 10 additions & 10 deletions otto.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// otto.module :: otto.go
//
// Copyright (c) 2017-2020 Akinori Hattori <hattya@gmail.com>
// Copyright (c) 2017-2023 Akinori Hattori <hattya@gmail.com>
//
// SPDX-License-Identifier: MIT
//
Expand All @@ -20,7 +20,7 @@ func Throw(vm *otto.Otto, err error) otto.Value {
switch err := err.(type) {
case *otto.Error:
panic(err)
case parser.ErrorList:
case *parser.ErrorList:
panic(vm.MakeSyntaxError(OttoError{Err: err}.Error()))
case ModuleError:
if err, ok := err.Err.(PackageError); ok {
Expand All @@ -33,7 +33,7 @@ func Throw(vm *otto.Otto, err error) otto.Value {
func Wrap(err error) error {
switch err.(type) {
case *otto.Error:
case parser.ErrorList:
case *parser.ErrorList:
default:
return err
}
Expand All @@ -48,16 +48,16 @@ func (e OttoError) Error() string {
switch err := e.Err.(type) {
case *otto.Error:
return strings.TrimSpace(err.String())
case parser.ErrorList:
name := err[0].Position.Filename
if name == "" {
name = "<anonymous>"
case *parser.ErrorList:
err1 := (*err)[0]
if err1.Position.Filename == "" {
err1.Position.Filename = "<anonymous>"
}
s := fmt.Sprintf("%v:%v:%v: %v", name, err[0].Position.Line, err[0].Position.Column, err[0].Message)
if len(err) == 1 {
s := fmt.Sprintf("%v:%v:%v: %v", err1.Position.Filename, err1.Position.Line, err1.Position.Column, err1.Message)
if len(*err) == 1 {
return s
}
return fmt.Sprintf("%v (and %v more errors)", s, len(err)-1)
return fmt.Sprintf("%v (and %v more errors)", s, len(*err)-1)
}
return e.Err.Error()
}

0 comments on commit 8438061

Please sign in to comment.