RPC_service: register Not_found error

This commit is contained in:
Milo Davis 2018-03-24 09:12:30 -04:00 committed by Benjamin Canou
parent 632144b689
commit 4c03952e43

View File

@ -148,3 +148,24 @@ let make_streamed_call s (ctxt : #streamed) p q i =
and on_close () = push None in
ctxt#call_streamed_service s ~on_chunk ~on_close p q i >>=? fun close ->
return (stream, close)
let () =
let open Data_encoding in
let uri_encoding =
conv
Uri.to_string
Uri.of_string
string in
register_error_kind
`Branch
~id:"RPC_context.Not_found"
~title:"RPC lookup failed"
~description:"RPC lookup failed. No RPC exists at the URL or the RPC tried to access non-existant data."
(obj2
(req "method" RPC_service.meth_encoding)
(req "uri" uri_encoding))
~pp:(fun ppf (_meth, _uri) ->
Format.fprintf ppf "Did not find service")
(function Not_found { meth ; uri } -> Some (meth, uri)
| _ -> None)
(fun (meth, uri) -> Not_found { meth ; uri })