mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
expose Response.Bad_req
This commit is contained in:
parent
5a38ffdce7
commit
7de89bd555
2 changed files with 8 additions and 2 deletions
|
|
@ -63,6 +63,8 @@ let make ?headers ?(code = 200) r : t =
|
|||
let fail ?headers ~code fmt =
|
||||
Printf.ksprintf (fun msg -> make_raw ?headers ~code msg) fmt
|
||||
|
||||
exception Bad_req = Bad_req
|
||||
|
||||
let fail_raise ~code fmt =
|
||||
Printf.ksprintf (fun msg -> raise (Bad_req (code, msg))) fmt
|
||||
|
||||
|
|
|
|||
|
|
@ -99,10 +99,14 @@ val fail : ?headers:Headers.t -> code:int -> ('a, unit, string, t) format4 -> 'a
|
|||
Example: [fail ~code:404 "oh noes, %s not found" "waldo"].
|
||||
*)
|
||||
|
||||
exception Bad_req of int * string
|
||||
(** Exception raised by {!fail_raise} with the HTTP code and body *)
|
||||
|
||||
val fail_raise : code:int -> ('a, unit, string, 'b) format4 -> 'a
|
||||
(** Similar to {!fail} but raises an exception that exits the current handler.
|
||||
This should not be used outside of a (path) handler.
|
||||
Example: [fail_raise ~code:404 "oh noes, %s not found" "waldo"; never_executed()]
|
||||
This should not be used outside of a (path) handler.
|
||||
Example: [fail_raise ~code:404 "oh noes, %s not found" "waldo"; never_executed()]
|
||||
@raise Bad_req always
|
||||
*)
|
||||
|
||||
val pp : Format.formatter -> t -> unit
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue