aboutsummaryrefslogtreecommitdiff
path: root/object/object.go
diff options
context:
space:
mode:
authorBobby <[email protected]>2024-03-04 08:38:06 -0500
committerBobby <[email protected]>2024-03-04 08:38:06 -0500
commitc430bfcae07489ad52ae65cadee581be72dd35d1 (patch)
treee6c6be7e48a3b34fbc5d6354d21945acf4623332 /object/object.go
parentf793e4bac77ff15949e510b135cf917a303698f4 (diff)
downloadmana-c430bfcae07489ad52ae65cadee581be72dd35d1.tar.xz
mana-c430bfcae07489ad52ae65cadee581be72dd35d1.zip
error handling
Diffstat (limited to 'object/object.go')
-rw-r--r--object/object.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/object/object.go b/object/object.go
index fbecf88..20deb0c 100644
--- a/object/object.go
+++ b/object/object.go
@@ -9,6 +9,7 @@ const (
BOOLEAN_OBJ = "BOOLEAN"
NULL_OBJ = "NULL"
RETURN_VALUE_OBJ = "RETURN_VALUE"
+ ERROR_OBJ = "ERROR"
)
type Object interface {
@@ -30,6 +31,10 @@ type ReturnValue struct {
Value Object
}
+type Error struct {
+ Message string
+}
+
func (i *Integer) Type() ObjectType {
return INTEGER_OBJ
}
@@ -61,3 +66,6 @@ func (rv *ReturnValue) Type() ObjectType {
func (rv *ReturnValue) Inspect() string {
return rv.Value.Inspect()
}
+
+func (e *Error) Type() ObjectType { return ERROR_OBJ }
+func (e *Error) Inspect() string { return "ERROR:" + e.Message }