libpostal_rust/errors.rs
1//! Error types.
2
3use thiserror::Error;
4
5/// A `libpostal`-related error.
6#[derive(Error, Debug)]
7#[non_exhaustive]
8pub enum Error {
9 /// We could initialize libpostal for some reason.
10 #[error("could not initialize libpostal ({component})")]
11 #[non_exhaustive]
12 InitializationFailed { component: &'static str },
13
14 /// The `libpostal` data directory was not found in any of the usual
15 /// locations.
16 #[error("could not find libpostal data in any of {candidates:?}")]
17 #[non_exhaustive]
18 NoDataDir { candidates: &'static [&'static str] },
19
20 /// We cannot pass strings with `\0` bytes to C.
21 #[error("found a '\0' byte in {string:?}")]
22 #[non_exhaustive]
23 NullByteInString { string: String },
24}