Files
monkey/internal/object/errors.go
Charles Smith a85dc73954
Some checks failed
Build / build (push) Successful in 10m47s
Publish Image / publish (push) Failing after 30s
Test / build (push) Successful in 11m0s
Switching to wsl
2024-03-31 19:35:04 -04:00

21 lines
545 B
Go

package object
import (
"fmt"
)
// BinaryOpError is an binary operation error usually resulting from mismatched types
type BinaryOpError struct {
left, right Object
op string
}
func (e BinaryOpError) Error() string {
return fmt.Sprintf("unsupported types for binary operation: %s %s %s %s %s", e.left.Type(), e.left.Inspect(), e.op, e.right.Type(), e.right.Inspect())
}
// NewBinaryOpError returns a new BinaryOpError
func NewBinaryOpError(left, right Object, op string) BinaryOpError {
return BinaryOpError{left, right, op}
}