use thiserror::Error as ThisError;
use crate::error::{Error, ErrorKind};
#[derive(Clone, Debug, ThisError)]
#[non_exhaustive]
pub enum Decimal128ErrorKind {
#[error("empty exponent")]
#[non_exhaustive]
EmptyExponent {},
#[error("invalid exponent")]
#[non_exhaustive]
InvalidExponent {},
#[error("invalid coefficient")]
#[non_exhaustive]
InvalidCoefficient {},
#[error("overflow")]
#[non_exhaustive]
Overflow {},
#[error("underflow")]
#[non_exhaustive]
Underflow {},
#[error("inexact rounding")]
#[non_exhaustive]
InexactRounding {},
#[error("unparseable")]
#[non_exhaustive]
Unparseable {},
}
impl Error {
pub(crate) fn decimal128(kind: Decimal128ErrorKind) -> Self {
ErrorKind::Decimal128 { kind }.into()
}
#[cfg(test)]
pub(crate) fn is_decimal128_unparseable(&self) -> bool {
matches!(
self.kind,
ErrorKind::Decimal128 {
kind: Decimal128ErrorKind::Unparseable {},
}
)
}
}