drcp_format/reader/
error.rs

1use std::io;
2use std::num::NonZero;
3
4use chumsky::span::SimpleSpan;
5
6#[cfg(doc)]
7use super::ProofReader;
8
9/// The errors that can be encountered by the [`ProofReader`].
10#[derive(Debug, thiserror::Error)]
11pub enum Error {
12    #[error("failed to read from source: {0}")]
13    IoError(#[from] io::Error),
14
15    #[error("failed to parse proof line {line_nr} {span:?}: {reason}")]
16    ParseError {
17        line_nr: usize,
18        reason: String,
19        span: (usize, usize),
20    },
21
22    #[error("undefined atomic {code} on line {line}")]
23    UndefinedAtomic { line: usize, code: NonZero<i32> },
24}
25
26impl Error {
27    pub(super) fn parse_error(line_nr: usize, reason: String, span: SimpleSpan) -> Self {
28        Error::ParseError {
29            line_nr,
30            span: (span.start, span.end),
31            reason,
32        }
33    }
34}