mirror of
https://github.com/aantron/dream.git
synced 2025-12-31 00:03:52 -05:00
Insert the Dream.catch middleware to have it handle all errors and exceptions
in one place:
let () =
Dream.run
@@ Dream.logger
@@ Dream.catch ~debug:true
@@ Dream.router [
Dream.get "/"
(fun _ ->
Dream.respond "Good morning, world!");
Dream.get "/bad"
(fun _ ->
Dream.respond ~status:`Bad_request "");
Dream.get "/fail"
(fun _ ->
raise (Failure "The web app had a fail!"));
]
@@ fun _ ->
Dream.respond ~status:`Not_found ""
Where to go from here?
5-catchhandles errors from all your handlers in one place.