From b059c2364d54c34d85ce791546aeeefd0a3c43b6 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 25 Aug 2025 09:40:57 -0400 Subject: make runtime errors std::error::Error --- src/forth/vm.rs | 8 ++++++++ 1 file changed, 8 insertions(+) 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 { -- cgit v1.3