-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstd_error.rs
More file actions
34 lines (27 loc) · 1.04 KB
/
std_error.rs
File metadata and controls
34 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-FileCopyrightText: 2021 - 2025 Robin Vobruba <hoijui.quaero@gmail.com>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use crate::BoxError;
use thiserror::Error;
/// This serves to wrap/represent `std::**()` and `Option` return values as `Result`s,
/// like the one of [`std::path::Path::file_name()`], or [`std::ffi::OsStr::to_str()`].
#[derive(Error, Debug)]
pub enum Error {
#[error("Represents a `Option::None` value as an error.")]
None,
#[error(r#"The file name ends in "..", and does therefore not represent a file/directory/valid path."#)]
PathNotAFile,
#[error(
"The string is not valid UTF-8, and can thus not be represented by a normal rust string."
)]
NotValidUtf8,
#[cfg(feature = "url_parse_error")]
#[error(transparent)]
InvalidUrl(#[from] url::ParseError),
/// Represents all cases of `std::io::Error`.
#[error(transparent)]
IO(#[from] std::io::Error),
/// Represents all other cases of `std::error::Error`.
#[error(transparent)]
Boxed(#[from] BoxError),
}