ark_linear_sumcheck/
error.rs

1use ark_std::fmt;
2
3use ark_std::string::String;
4use core::fmt::Formatter;
5/// Error type for this crate
6#[derive(fmt::Debug)]
7pub enum Error {
8    /// protocol rejects this proof
9    Reject(Option<String>),
10    /// IO Error
11    IOError,
12    /// Serialization Error
13    SerializationError,
14    /// Random Generator Error
15    RNGError,
16    /// Other caused by other operations
17    OtherError(String),
18}
19
20impl fmt::Display for Error {
21    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
22        if let Self::OtherError(s) = self {
23            f.write_str(s)
24        } else {
25            f.write_fmt(format_args!("{self:?}"))
26        }
27    }
28}
29
30impl ark_std::error::Error for Error {}
31
32impl From<ark_std::io::Error> for Error {
33    fn from(_: ark_std::io::Error) -> Self {
34        Self::IOError
35    }
36}
37
38impl From<ark_serialize::SerializationError> for Error {
39    fn from(_: ark_serialize::SerializationError) -> Self {
40        Self::SerializationError
41    }
42}
43impl From<ark_std::rand::Error> for Error {
44    fn from(_: ark_std::rand::Error) -> Self {
45        Self::RNGError
46    }
47}