LCOV - differential code coverage report
Current view: top level - proxy/src - error.rs (source / functions) Coverage Total Hit UBC
Current: f6946e90941b557c917ac98cd5a7e9506d180f3e.info Lines: 0.0 % 10 0 10
Current Date: 2023-10-19 02:04:12 Functions: 0.0 % 12 0 12
Baseline: c8637f37369098875162f194f92736355783b050.info
Baseline Date: 2023-10-18 20:25:20

           TLA  Line data    Source code
       1                 : use std::{error::Error as StdError, fmt, io};
       2                 : 
       3                 : /// Upcast (almost) any error into an opaque [`io::Error`].
       4 UBC           0 : pub fn io_error(e: impl Into<Box<dyn StdError + Send + Sync>>) -> io::Error {
       5               0 :     io::Error::new(io::ErrorKind::Other, e)
       6               0 : }
       7                 : 
       8                 : /// A small combinator for pluggable error logging.
       9               0 : pub fn log_error<E: fmt::Display>(e: E) -> E {
      10               0 :     tracing::error!("{e}");
      11               0 :     e
      12               0 : }
      13                 : 
      14                 : /// Marks errors that may be safely shown to a client.
      15                 : /// This trait can be seen as a specialized version of [`ToString`].
      16                 : ///
      17                 : /// NOTE: This trait should not be implemented for [`anyhow::Error`], since it
      18                 : /// is way too convenient and tends to proliferate all across the codebase,
      19                 : /// ultimately leading to accidental leaks of sensitive data.
      20                 : pub trait UserFacingError: fmt::Display {
      21                 :     /// Format the error for client, stripping all sensitive info.
      22                 :     ///
      23                 :     /// Although this might be a no-op for many types, it's highly
      24                 :     /// recommended to override the default impl in case error type
      25                 :     /// contains anything sensitive: various IDs, IP addresses etc.
      26                 :     #[inline(always)]
      27               0 :     fn to_string_client(&self) -> String {
      28               0 :         self.to_string()
      29               0 :     }
      30                 : }
        

Generated by: LCOV version 2.1-beta