From: Ian Jackson Date: Wed, 17 Feb 2021 21:27:20 +0000 (+0000) Subject: internal_logic_error: Provide and use internal_error_bydebug X-Git-Tag: otter-0.4.0~426 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=9b261f25a43c726e6aa988772edc3b87edf49593;p=otter.git internal_logic_error: Provide and use internal_error_bydebug No change other than to internal error messages. Signed-off-by: Ian Jackson --- diff --git a/src/error.rs b/src/error.rs index 11cccb37..336a8cbb 100644 --- a/src/error.rs +++ b/src/error.rs @@ -59,6 +59,10 @@ pub struct InternalLogicError { backtrace: parking_lot::Mutex, } +pub fn internal_error_bydebug(desc: &dyn Debug) -> IE { + internal_logic_error(format!("{:?}", desc)) +} + pub fn internal_logic_error>>(desc: S) -> IE { let backtrace = backtrace::Backtrace::new_unresolved(); IE::InternalLogicError(InternalLogicError { diff --git a/src/hidden.rs b/src/hidden.rs index 220a8c98..5dfd82c6 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -332,9 +332,7 @@ fn recalculate_occultation_general< let h = occulteds[oni].as_ref().ok_or_else( || internal_logic_error("most obscure not obscure"))?; let opiece = h.occ.occulter; - let bad = || internal_logic_error( - format!("missing occulter piece {:?} for occid {:?}", - opiece, h.occid)); + let bad = || internal_error_bydebug(&("missing", opiece, h.occid)); let oipc = ipieces.get(opiece).ok_or_else(bad)?; let ogpc = gs.pieces.get(opiece).ok_or_else(bad)?; Ok::<_,IE>(oipc.describe_html(None, ogpc)?) diff --git a/src/shapelib.rs b/src/shapelib.rs index 26743e3e..0a0fbea4 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -83,8 +83,8 @@ pub enum LibraryLoadError { } impl LibraryLoadError { - fn ought(self) -> InternalError { - internal_logic_error(format!("{:?}", self)) + fn ought(&self) -> InternalError { + internal_error_bydebug(self) } }