Skip to main content

oak_python/errors/
mod.rs

1#[cfg(feature = "serde")]
2use serde::{Deserialize, Serialize};
3
4/// Python parse errors.
5#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
6#[derive(Copy, Clone, Debug)]
7pub enum ParseError {
8    /// Invalid request error.
9    InvalidRequest,
10}
11
12impl ParseError {
13    /// Creates a new invalid request error.
14    pub fn new() -> Self {
15        Self::InvalidRequest
16    }
17}
18
19/// Represents a failure during parsing.
20pub struct Fail {
21    /// The underlying parse error.
22    pub error: ParseError,
23}
24
25impl Fail {
26    /// Creates a new failure.
27    pub fn new(error: ParseError) -> Self {
28        Self { error }
29    }
30}
31
32/// Pex error structure.
33pub struct PexError {
34    /// Kind of the error.
35    pub kind: PexErrorKind,
36}
37
38impl PexError {
39    /// Creates a new Pex error.
40    pub fn new(kind: PexErrorKind) -> Self {
41        Self { kind }
42    }
43}
44
45/// Kinds of Pex errors.
46pub enum PexErrorKind {
47    /// Syntax error.
48    SyntaxError {},
49}
50
51impl PexErrorKind {
52    /// Creates a new syntax error kind.
53    pub fn new_syntax_error() -> Self {
54        Self::SyntaxError {}
55    }
56}