-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e126c82
commit f47fdb5
Showing
4 changed files
with
117 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
package object | ||
|
||
import "fmt" | ||
import ( | ||
"fmt" | ||
) | ||
|
||
// Error represents a custom error type with an associated message. | ||
type Error struct { | ||
Message string | ||
} | ||
|
||
// Inspect returns a formatted string representation of the error. | ||
func (e *Error) Inspect() string { | ||
msg := fmt.Sprintf("\x1b[%dm%s\x1b[0m", 31, "Error: ") | ||
return msg + e.Message | ||
return fmt.Sprintf("\x1b[1;31mError:\x1b[0m %s", e.Message) | ||
} | ||
|
||
// Type returns the object type of the error. | ||
func (e *Error) Type() ObjectType { | ||
return ERROR_OBJ | ||
} | ||
func (e *Error) Type() ObjectType { return ERROR_OBJ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters