fast_yaml_parallel/
error.rs1use std::path::PathBuf;
4
5use fast_yaml_core::ParseError as CoreParseError;
6use thiserror::Error;
7
8#[derive(Error, Debug)]
10pub enum Error {
11 #[error("failed to parse document at index {index}")]
13 Parse {
14 index: usize,
16
17 #[source]
19 source: CoreParseError,
20 },
21
22 #[error("failed to read '{path}': {source}")]
24 Io {
25 path: PathBuf,
27
28 #[source]
30 source: std::io::Error,
31 },
32
33 #[error("file is not valid UTF-8: {source}")]
35 Utf8 {
36 #[source]
38 source: std::str::Utf8Error,
39 },
40
41 #[error("format error: {message}")]
43 Format {
44 message: String,
46 },
47
48 #[error("failed to write '{path}': {source}")]
50 Write {
51 path: PathBuf,
53
54 #[source]
56 source: std::io::Error,
57 },
58
59 #[error("input size {size} bytes exceeds maximum {max} bytes")]
61 InputTooLarge {
62 size: usize,
64
65 max: usize,
67 },
68
69 #[error("chunking failed: {0}")]
71 Chunking(String),
72
73 #[error("thread pool error: {0}")]
75 ThreadPool(String),
76
77 #[error("configuration error: {0}")]
79 Config(String),
80}
81
82pub type Result<T> = std::result::Result<T, Error>;
84
85impl From<std::str::Utf8Error> for Error {
86 fn from(source: std::str::Utf8Error) -> Self {
87 Self::Utf8 { source }
88 }
89}