File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed
Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 2323[%% shared open Eliom_content.Html.F ]
2424[%% client open Eliom_shared ]
2525
26- let % shared default_fail e =
26+ let % shared default_fail_fun e =
2727 [
2828 if Eliom_config. get_debugmode ()
2929 then em [ pcdata (Printexc. to_string e) ]
@@ -36,6 +36,19 @@ let%shared default_fail e =
3636 end
3737 ]
3838
39+ let % shared default_fail_ref
40+ : (exn -> Html_types. div_content Eliom_content.Html. elt list ) ref
41+ = ref default_fail_fun
42+
43+ let % shared default_fail e =
44+ (! default_fail_ref e
45+ : Html_types. div_content Eliom_content.Html. elt list
46+ :> [< Html_types. div_content ] Eliom_content.Html. elt list )
47+
48+ let % shared set_default_fail f = default_fail_ref :=
49+ (f : exn -> [< Html_types. div_content ] Eliom_content.Html. elt list
50+ :> exn -> Html_types.div_content Eliom_content.Html.elt list )
51+
3952let % server with_spinner ?(a = [] ) ?fail thread =
4053 let a = (a :> Html_types.div_attrib attrib list ) in
4154 let fail =
@@ -78,7 +91,10 @@ let cl_spinner = "ot-icon-spinner"
7891
7992let replace_content ?fail elt thread =
8093 let fail = match fail with
81- | Some fail -> fail
94+ | Some fail ->
95+ (fail
96+ : exn -> [< Html_types. div_content ] Eliom_content.Html. elt list Lwt. t
97+ :> exn -> Html_types. div_content Eliom_content.Html. elt list Lwt. t)
8298 | None -> fun e -> Lwt. return (default_fail e)
8399 in
84100 inc_active_spinners () ;
Original file line number Diff line number Diff line change 3333
3434 If you want the spinner on both sides, you can use [with_spinner_no_lwt]
3535 and [Eliom_content.Html.C.node].
36+
37+ Function [fail] will be used to display block in case an exception is
38+ raised.
3639 *)
3740val with_spinner :
3841 ?a : [< Html_types .div_attrib ] Eliom_content.Html .attrib list ->
@@ -57,9 +60,9 @@ val with_spinner_no_lwt :
5760 generated by [thread]. The [elt] has be a D-node. Until [thread] is
5861 finished [elt] is transformed into a spinner. *)
5962val replace_content :
60- ?fail : (exn -> ([> Html_types .em ] as 'b ) Eliom_content.Html .elt list Lwt .t ) ->
63+ ?fail : (exn -> [< Html_types .div_content ] Eliom_content.Html .elt list Lwt .t ) ->
6164 'a Eliom_content.Html .elt ->
62- 'b Eliom_content.Html .elt list Lwt .t -> unit Lwt .t
65+ Html_types .div_content Eliom_content.Html .elt list Lwt .t -> unit Lwt .t
6366
6467(* * the number of spinners currently spinning *)
6568val num_active_spinners : int Eliom_shared.React .S .t
@@ -68,3 +71,7 @@ val num_active_spinners : int Eliom_shared.React.S.t
6871val onloaded : unit Eliom_shared.React .E .t
6972(* * do an action once no spinners are spinning (could be right away) *)
7073val when_loaded : (unit -> unit ) -> unit
74+
75+ (* * Change the default function used to display error messages *)
76+ val set_default_fail :
77+ (exn -> [< Html_types .div_content ] Eliom_content.Html .elt list ) -> unit
You can’t perform that action at this time.
0 commit comments