From: Ian Jackson Date: Wed, 27 Apr 2022 22:13:33 +0000 (+0100) Subject: api: setz: Avoid an unwrap X-Git-Tag: otter-1.1.0~417 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=d623c46058644e2561e2806a165591b4eb37677d;p=otter.git api: setz: Avoid an unwrap Panicking is worse than failing. Spotted this in passing. Signed-off-by: Ian Jackson --- diff --git a/daemon/api.rs b/daemon/api.rs index dd7756a9..4a59b5b6 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -456,7 +456,7 @@ api_route!{ #[throws(ApiPieceOpError)] fn op(&self, a: ApiPieceOpArgs) -> PieceUpdate { let ApiPieceOpArgs { gs,piece, .. } = a; - let gpc = gs.pieces.byid_mut(piece).unwrap(); + let gpc = gs.pieces.byid_mut(piece)?; if gpc.occult.is_active() { if self.z >= gpc.zlevel.z { throw!(Ia::Occultation) } }