dune_raw/error.rs
1/// Rawfile reading errors.
2///
3/// Fatal conditions mirror the 3f5 reader: a non-blank line that is not a
4/// recognized keyword aborts the load ("strange line in rawfile"), and so
5/// does truncated or unparsable data. Recoverable oddities become
6/// [`crate::Rawfile::warnings`] instead.
7#[derive(Debug, thiserror::Error)]
8pub enum Error {
9 #[error("i/o error: {0}")]
10 Io(#[from] std::io::Error),
11
12 #[error("line {line}: {msg}")]
13 Parse { line: usize, msg: String },
14}
15
16impl Error {
17 pub(crate) fn parse(line: usize, msg: impl Into<String>) -> Self {
18 Error::Parse {
19 line,
20 msg: msg.into(),
21 }
22 }
23}