package async_rpc_kernel

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file on_exception.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
open Core
open Async_kernel

type t = Implementation_types.On_exception.t =
  { callback : (exn -> unit) option [@sexp.omit_nil]
  ; close_connection_if_no_return_value : bool
  }
[@@deriving sexp_of]

let close_connection = { callback = None; close_connection_if_no_return_value = true }
let continue = { callback = None; close_connection_if_no_return_value = false }

let handle_exn
  { callback; close_connection_if_no_return_value }
  ~close_connection_monitor
  exn
  =
  Option.iter callback ~f:(fun callback -> callback exn);
  if close_connection_if_no_return_value
  then Monitor.send_exn close_connection_monitor exn
;;