fix: catch TLS.Not_set

This commit is contained in:
Simon Cruanes 2024-08-30 13:27:04 -04:00
parent 704ebdae58
commit 3193a259ad
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -27,8 +27,13 @@ let[@inline] get_current_fiber () : fiber option =
match TLS.get_exn k_cur_fiber with
| f when f != _dummy_fiber -> Some f
| _ -> None
| exception TLS.Not_set -> None
let error_get_current_fiber_ =
"Moonpool: get_current_fiber was called outside of a fiber."
let[@inline] get_current_fiber_exn () : fiber =
match TLS.get_exn k_cur_fiber with
| f when f != _dummy_fiber -> f
| _ -> failwith "Moonpool: get_current_fiber was called outside of a fiber."
| _ -> failwith error_get_current_fiber_
| exception TLS.Not_set -> failwith error_get_current_fiber_