diff options
| author | Bobby <[email protected]> | 2024-03-04 08:38:06 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2024-03-04 08:38:06 -0500 |
| commit | c430bfcae07489ad52ae65cadee581be72dd35d1 (patch) | |
| tree | e6c6be7e48a3b34fbc5d6354d21945acf4623332 /object | |
| parent | f793e4bac77ff15949e510b135cf917a303698f4 (diff) | |
| download | mana-c430bfcae07489ad52ae65cadee581be72dd35d1.tar.xz mana-c430bfcae07489ad52ae65cadee581be72dd35d1.zip | |
error handling
Diffstat (limited to 'object')
| -rw-r--r-- | object/object.go | 8 |
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 } |
