From: Ian Jackson Date: Sat, 30 Jan 2021 23:46:14 +0000 (+0000) Subject: daemon: Fix many errors (OER rather than OE) X-Git-Tag: otter-0.4.0~618 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=6143ace1a042c6c63ece2649ca7d5dce2139d742;p=otter.git daemon: Fix many errors (OER rather than OE) Firstly, all these functions shuuld throw OER which is the thing which implements the Rocket Responder trait, so that the error actually goes back to the client. Secondly, they all need ?. Without that, these functions all always succeed and always return Result::Ok(some Result<, OE[R]>). Surprisingly this is accepted, because Result<> impl Responder and apparently Result> does too! Signed-off-by: Ian Jackson --- diff --git a/daemon/api.rs b/daemon/api.rs index 97c3779b..eea0cdce 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -177,10 +177,10 @@ fn api_piece_op(form : Json>) struct ApiPieceGrab { } #[post("/_/api/grab", format="json", data="
")] -#[throws(OE)] +#[throws(OER)] fn api_grab(form : Json>) -> impl response::Responder<'static> { - api_piece_op(form) + api_piece_op(form)? } impl ApiPieceOp for ApiPieceGrab { #[throws(ApiPieceOpError)] @@ -204,10 +204,10 @@ impl ApiPieceOp for ApiPieceGrab { struct ApiPieceWrest { } #[post("/_/api/wrest", format="json", data="")] -#[throws(OE)] +#[throws(OER)] fn api_wrest(form : Json>) -> impl response::Responder<'static> { - api_piece_op(form) + api_piece_op(form)? } impl ApiPieceOp for ApiPieceWrest { #[throws(OnlineError)] @@ -243,10 +243,10 @@ impl ApiPieceOp for ApiPieceWrest { struct ApiPieceUngrab { } #[post("/_/api/ungrab", format="json", data="")] -#[throws(OE)] +#[throws(OER)] fn api_ungrab(form : Json>) -> impl response::Responder<'static> { - api_piece_op(form) + api_piece_op(form)? } impl ApiPieceOp for ApiPieceUngrab { #[throws(ApiPieceOpError)] @@ -271,10 +271,10 @@ struct ApiPieceSetZ { z : ZCoord, } #[post("/_/api/setz", format="json", data="")] -#[throws(OE)] +#[throws(OER)] fn api_raise(form : Json>) -> impl response::Responder<'static> { - api_piece_op(form) + api_piece_op(form)? } impl ApiPieceOp for ApiPieceSetZ { #[throws(ApiPieceOpError)] @@ -291,9 +291,9 @@ impl ApiPieceOp for ApiPieceSetZ { #[derive(Debug,Serialize,Deserialize)] struct ApiPieceMove (Pos); #[post("/_/api/m", format="json", data="")] -#[throws(OE)] +#[throws(OER)] fn api_move(form : Json>) -> impl response::Responder<'static> { - api_piece_op(form) + api_piece_op(form)? } impl ApiPieceOp for ApiPieceMove { #[throws(ApiPieceOpError)] @@ -318,9 +318,9 @@ impl ApiPieceOp for ApiPieceMove { #[derive(Debug,Serialize,Deserialize)] struct ApiPieceRotate(CompassAngle); #[post("/_/api/rotate", format="json", data="")] -#[throws(OE)] +#[throws(OER)] fn api_rotate(form : Json>) -> impl response::Responder<'static> { - api_piece_op(form) + api_piece_op(form)? } impl ApiPieceOp for ApiPieceRotate { #[throws(ApiPieceOpError)] @@ -339,9 +339,9 @@ impl ApiPieceOp for ApiPieceRotate { #[derive(Debug,Serialize,Deserialize)] struct ApiPiecePin (bool); #[post("/_/api/pin", format="json", data="")] -#[throws(OE)] +#[throws(OER)] fn api_pin(form : Json>) -> impl response::Responder<'static> { - api_piece_op(form) + api_piece_op(form)? } impl ApiPieceOp for ApiPiecePin { #[throws(ApiPieceOpError)] @@ -365,9 +365,9 @@ const DEFKEY_FLIP : UoKey = 'f'; #[derive(Debug,Serialize,Deserialize)] struct ApiPieceUo { opname: String, wrc: WhatResponseToClientOp } #[post("/_/api/k", format="json", data="")] -#[throws(OE)] +#[throws(OER)] fn api_uo(form : Json>) -> impl response::Responder<'static> { - api_piece_op(form) + api_piece_op(form)? } impl ApiPieceOp for ApiPieceUo { #[throws(ApiPieceOpError)] diff --git a/daemon/main.rs b/daemon/main.rs index 4c34e740..da569460 100644 --- a/daemon/main.rs +++ b/daemon/main.rs @@ -165,7 +165,7 @@ impl<'r, T> FromParam<'r> for Parse } #[get("/_/updates?&")] -#[throws(OE)] +#[throws(OER)] fn updates<'r>(ctoken : InstanceAccess, gen: u64, cors: rocket_cors::Guard<'r>) -> impl response::Responder<'r> {