From 7cc0073a3e569df06bedd4018b4d3b3c7bd93259 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 22 Jan 2020 21:03:24 -0800 Subject: [PATCH] hmm my first idea was bad but not too bad --- crates/generate/src/errors.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/generate/src/errors.rs b/crates/generate/src/errors.rs index d1b4bbfbc3..2dc2f243b0 100644 --- a/crates/generate/src/errors.rs +++ b/crates/generate/src/errors.rs @@ -7,6 +7,18 @@ use witx::{Document, TypeRef}; /// The context struct needs to implement a trait for converting memory and value errors into the /// witx doc's error types. +/// +// XXX im rethinking this. maybe each error type should impl +// pub trait WitxErrorType { +// type Context; +// fn is_success(&self) -> bool; +// fn from_memory_error(memory_error: MemoryError, ctx: &mut Context) -> Self; +// fn from_value_error(value_error: GuestValueError, ctx: &mut Context) -> Self; +// } +// +// where Context is mapped to their wasi ctx. +// It seems less "magic" to leave that impl up to the user, and the error message may be simpler? +// pub fn define_error_trait(names: &Names, doc: &Document) -> TokenStream { // All non-anonymous first return types are used to pass errors. let error_typenames = doc