otp_std/auth/
utf8.rs

1//! UTF-8 errors.
2
3use std::string::FromUtf8Error;
4
5use miette::Diagnostic;
6use thiserror::Error;
7
8/// Wraps [`FromUtf8Error`] to provide diagnostics.
9#[derive(Debug, Error, Diagnostic)]
10#[error("invalid utf-8 encountered when decoding")]
11#[diagnostic(
12    code(opt_std::auth::utf8),
13    help("make sure the part decodes to valid utf-8")
14)]
15pub struct Error(#[from] pub FromUtf8Error);
16
17/// Wraps the given error into [`struct@Error`].
18pub const fn wrap(error: FromUtf8Error) -> Error {
19    Error(error)
20}