use thiserror::Error;
use crate::error::error_impl::impl_into_cot_error;
#[expect(clippy::doc_link_with_quotes, reason = "404 Not Found link")]
#[derive(Debug, Error)]
#[non_exhaustive]
#[error(transparent)]
pub struct NotFound {
pub kind: Kind,
}
impl_into_cot_error!(NotFound, NOT_FOUND);
impl NotFound {
#[must_use]
pub fn new() -> Self {
Self::with_kind(Kind::Custom)
}
#[must_use]
pub fn with_message<T: Into<String>>(message: T) -> Self {
Self::with_kind(Kind::WithMessage(message.into()))
}
#[must_use]
pub(crate) fn router() -> Self {
Self::with_kind(Kind::FromRouter)
}
#[must_use]
fn with_kind(kind: Kind) -> Self {
NotFound { kind }
}
}
impl Default for NotFound {
fn default() -> Self {
Self::new()
}
}
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum Kind {
#[error("Not Found")]
#[non_exhaustive]
FromRouter,
#[error("Not Found")]
#[non_exhaustive]
Custom,
#[error("Not Found: {0}")]
#[non_exhaustive]
WithMessage(String),
}