package eio
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=8ed5c13e6689f31c85dca5f12762d84b8cc0042a7b07d3e464df6eb4b72b3dfc
sha512=46e8f817f32c3316e7f35835a136ad177a295b3306351eb2efa2386482b0169a5b19ed2925b32da2a1f10d40f083fe3d588dd401908f9fec6e4a44cd68535204
doc/eio/Eio/Exn/index.html
Module Eio.ExnSource
Eio exceptions.
Describes the particular error that occurred.
They are typically nested (e.g. Fs (Permission_denied (Unix_error ...))) so that you can match e.g. all IO errors, all file-system errors, all permission denied errors, etc.
If you extend this, use register_pp to add a printer for the new error.
Extra information attached to an IO error. This provides contextual information about what caused the error.
A general purpose IO exception.
This is used for most errors interacting with the outside world, and is similar to Unix.Unix_error, but more general. An unknown Io error should typically be reported to the user, but does not generally indicate a bug in the program.
type err += | Multiple_io of (err * context * Printexc.raw_backtrace) list(*Error code used when multiple IO errors occur.
This is useful if you want to catch and report all IO errors.
*)
add_context ex msg returns a new exception with msg added to ex's context, if ex is an Io exception.
If ex is not an Io exception, this function just returns the original exception.
val reraise_with_context :
exn ->
Printexc.raw_backtrace ->
('a, Format.formatter, unit, 'b) format4 ->
'areraise_with_context ex bt msg raises ex extended with additional information msg.
ex should be an Io exception (if not, is re-raised unmodified).
Example:
try connect addr
with Eio.Io _ as ex ->
let bt = Printexc.get_raw_backtrace () in
reraise_with_context ex bt "connecting to %S" addrYou must get the backtrace before calling any other function in the exception handler to prevent corruption of the backtrace.
register_pp pp adds pp as a pretty-printer of errors.
pp f err should format err using f, if possible. It should return true on success, or false if it didn't recognise err.
A backtrace with no frames.
Raised if multiple fibers fail, to report all the exceptions.
This usually indicates a bug in the program.
Note: If multiple IO errors occur, then you will get Io (Multiple_io _, _) instead of this.
combine x y returns a single exception and backtrace to use to represent two errors.
The resulting exception is typically just Multiple [y; x], but various heuristics are used to simplify the result:
- Combining with a
Cancel.Cancelledexception does nothing, as these don't need to be reported. The result is onlyCancelledif there is no other exception available. - If both errors are
Ioerrors, then the result isIo (Multiple_io _).