Files
monkey/internal/object/error.go
Chuck Smith 07fd82b261
Some checks failed
Build / build (push) Successful in 10m29s
Publish Image / publish (push) Failing after 31s
Test / build (push) Failing after 6m34s
optimizations
2024-04-02 14:08:08 -04:00

46 lines
782 B
Go

package object
// error encountered. This object is tracked through the evaluator and when
// encountered stops evaluation of the program or body of a function.
type Error struct {
Message string
}
func (e Error) Bool() bool {
return false
}
func (e Error) Type() Type {
return ErrorType
}
func (e Error) Inspect() string {
return "Error: " + e.Message
}
// Copy implements the Copyable interface
func (e Error) Copy() Object {
return Error{Message: e.Message}
}
func (e Error) Compare(other Object) int {
if obj, ok := other.(Error); ok {
if e.Message > obj.Message {
return 1
}
if e.Message == obj.Message {
return 0
}
return -1
}
return -1
}
func (e Error) Error() string {
return e.Message
}
func (e Error) String() string {
return e.Message
}