janestreet / async_unix

Jane Street Capital's asynchronous execution library (unix)
MIT License
33 stars 21 forks source link

Extracting exception raised from inner monitor in writer #9

Closed copy closed 8 years ago

copy commented 8 years ago

In writer0.ml line 439, exceptions raised in the inner monitor are wrapped into Error. Is there a way to extract the original exception or handle this exception in another way? Error seems to be there only to provide human-readable messages.

I would like to ignore broken pipes exceptions like this:

(src/monitor.ml.Error_
  ((exn
     ("writer error"
       ((src/monitor.ml.Error_
          ((exn (Unix.Unix_error "Broken pipe" writev "")) (backtrace (""))
            (monitor
              (((name (id 39)) (here ()) (id 39) (has_seen_error true)
[…]
ghost commented 8 years ago

Note that for this particular problem, you can use ~raise_when_consumer_leave:false when creating the writer, and you can use Writer.consumer_left to be notified.

For you original question, you can't extract the original unix error. We usually don't match on exceptions directly

copy commented 8 years ago

Note that for this particular problem, you can use ~raise_when_consumer_leave:false when creating the writer, and you can use Writer.consumer_left to be notified.

This works for me, thanks.