rustypipe_botguard/
error.rs

1use std::borrow::Cow;
2
3/// Error type for the rustypipe-botguard library
4#[derive(thiserror::Error, Debug)]
5pub enum Error {
6    /// Error executing JavaScript
7    #[error("javscript: {0}")]
8    Js(Cow<'static, str>),
9    /// File I/O error
10    #[error("file I/O: {0}")]
11    Io(#[from] std::io::Error),
12    /// HTTP error
13    #[error("http: {0}")]
14    Http(#[from] reqwest::Error),
15    /// Could not parse snapshot file
16    #[error("invalid snapshot: {0}")]
17    InvalidSnapshot(Cow<'static, str>),
18    /// Could not parse challenge data
19    #[error("invalid challenge data: {0}")]
20    InvalidChallenge(Cow<'static, str>),
21    /// Could not parse challenge response data
22    #[error("invalid challenge response: {0}")]
23    InvalidResponse(Cow<'static, str>),
24    /// Generated an invalid PO token
25    #[error("invalid potoken: {0}")]
26    InvalidPoToken(Cow<'static, str>),
27}
28
29impl From<deno_core::error::CoreError> for Error {
30    fn from(value: deno_core::error::CoreError) -> Self {
31        Self::Js(value.to_string().into())
32    }
33}