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

error handling



not the most exciting topic perhaps, but traditionally seems thorny.

i'm trying to fix up ocaml-dns to be both a bit more correct and a bit more 
robust.

aiui, standard ocaml exceptions must not be allowed to propagate up to the 
point where they hit an Lwt thread, as that is Bad.

but there are a number of places in ocaml-dns -- and i expect that this will 
not be uncommon -- where functions raise exceptions indicating things like 
unparseable data (for whatever reason) has been received off the wire.

what i'd normally do here would be to cause current processing to cease, to 
return the unparseable data that caused the error so it can be logged, and 
continue from some suitable point.

my question is- what's the best way to do that under Lwt?

i've tried the following but have some questions:

1/ using raise_lwt instead of raise means that every function in question -- 
often these are subsidiary/helper functions  -- need to start returning 'a 
Lwt.t; does propagating the Lwt-ness all the way through matter at all, or do i 
just need to start doing lots of ">>" to chain things together, rather than 
using ";"?

2/ making return types 'a option rather than 'a -- but this does not work to 
return the unparseable bits

3/ logging the error (via Lwt_json_logger no less!) -- but this does not let me 
indicate that processing should stop at the appropriate place

4/ leaving the standard "raise" exceptions in and trying to be careful to catch 
them -- but this relies on me remembering all the entry points into the library 

currently i'm plumping for 4 but i wondered if the Gods of Ocaml had any better 
suggestions? :)

-- 
Cheers,

R.


This message and any attachment are intended solely for the addressee and may 
contain confidential information. If you have received this message in error, 
please send it back to me, and immediately delete it.   Please do not use, copy 
or disclose the information contained in this message or in any attachment.  
Any views or opinions expressed by the author of this email do not necessarily 
reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.


 


Rackspace

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