[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MirageOS-devel] Error handling in Mirage - request for comments!

Le mardi, 3 fÃvrier 2015 Ã 16:55, Christophe Troestler a Ãcrit :
> Please lay down a concrete interface showing of what you mean. I
> think we all agree on the goal of writing robust software, we need to
> move the discussion to concrete proposals.

Sorry don't have the time to work on this; these things come out of writing 
code. But as a start I don't see what's the problem with the basic result monad 
everybody knows (e.g. see here [1,2]) along with a few with_resource 
combinators based on some kind of `finally` [3] and stick to polymorphic 
variant errors â along, of course, with Format pretty printers for these 
something that is often annoyingly absent in APIs. And I would completely 
forget about using lwt's failed state (i.e. only to trap unexpected exceptions 
at the highest level).


This deals only with string errors so it should be generalized to [2], but a 
few of the error handling
combinators may be interesting.  


For example `reword_error` a quick combinator that allows to transform a 
lower-level error to a higher level one, i.e. give more context higher up when 
you have the info about what you are doing. Since we are using strings here 
it's also easy to stack the errors if you wish so (~replace:false argument) 
from the lowest-level of what went wrong (e.g. the actual utility invocation 
error) to what you were trying to do (e.g. determine the number of processors 
in the system) which makes error diagnosis much easier (context + no error info 
is lost). Not that it wouldn't be impossible with lists of polyvars, but one 
has to see how it comes out in practice. A few examples:


This is the classical generalized result type for dealing with errors.  

This could also be modified or another version provided to propagate possible 
errors in the finally handler in the concurrency monad itself.

MirageOS-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.