diff options
| author | Brian Cully <bjc@spork.org> | 2025-08-25 09:40:57 -0400 |
|---|---|---|
| committer | Brian Cully <bjc@spork.org> | 2025-08-25 09:40:57 -0400 |
| commit | b059c2364d54c34d85ce791546aeeefd0a3c43b6 (patch) | |
| tree | 2cd4e9ae9ae00edd814b2788dfaf705cb271a732 /src/forth/vm.rs | |
| parent | 74e271359b9df0fa74f98752eb22252b8dcc9ed8 (diff) | |
| download | automathon-b059c2364d54c34d85ce791546aeeefd0a3c43b6.tar.gz automathon-b059c2364d54c34d85ce791546aeeefd0a3c43b6.zip | |
make runtime errors std::error::Error
Diffstat (limited to 'src/forth/vm.rs')
| -rw-r--r-- | src/forth/vm.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/forth/vm.rs b/src/forth/vm.rs index a4f57c7..e4c01f2 100644 --- a/src/forth/vm.rs +++ b/src/forth/vm.rs @@ -114,6 +114,14 @@ pub struct VM { pub enum RuntimeError { StackUnderflow, } +impl std::fmt::Display for RuntimeError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::StackUnderflow => write!(f, "stack underflow"), + } + } +} +impl std::error::Error for RuntimeError {} impl VM { pub fn new(wordlist: WordList) -> Self { |
