Description
During some implementation for error-context
s in future
s in the wasip3-prototyping repo, we found that there was an issue with wasi:http/types#body.finish
, as it implicitly does a future.read
which can return a value or an error-context
in the case of an error.
There are a few ways that we can solve this (thanks to @rvolosatovs and @dicej for suggestions), but a short incomplete list follows:
- Change the
finish
method signature fromresult<option<trailers>, error-code>
toresult<option<result<trailers, error-context>>,error-code>
- Absorb the error and convert it into an existing
error-code
(likelyinternal-error
) - Create a new
error-code
variant that stores anerror-context
(1) is a reasonable approach but pollutes the type and possibly unreasonably forces caller to handle the error-context
directly.
(2) causes some loss of context in an almost certain future version of error-context
-- the best example is of an error context that can hold multiple traces (similar to an anyhow::Error
), if we were to boil down the error context into only a string
(given the current variants for error-code
)
(3) Seems like an ideal option as a variation of (2) -- an additional error variant like internal-error-context(error-context)
which would
There are of course other ways to handle this, so I'd like to open this up to discussion before submitting a PR to make the change (going for #3)