fnmatch_regex/error.rs
1// SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
2// SPDX-License-Identifier: BSD-2-Clause
3//! Common error definitions for the fnmatch crate.
4
5use anyhow::Error as AnyError;
6use regex::Error as RexError;
7use thiserror::Error;
8
9/// An error that occurred during the processing of a pattern.
10#[derive(Debug, Error)]
11#[non_exhaustive]
12#[allow(clippy::error_impl_error)]
13pub enum Error {
14 /// A bare escape character at the end of the pattern.
15 #[error("Bare escape character")]
16 BareEscape,
17
18 /// Something went really, really wrong.
19 #[error("fnmatch-regex internal error")]
20 InternalError(#[source] AnyError),
21
22 /// The resulting regex was invalid.
23 #[error("Could not compile the resulting pattern {0:?}")]
24 InvalidRegex(String, #[source] RexError),
25
26 /// Some known missing functionality.
27 #[error("Not implemented yet: {0}")]
28 NotImplemented(String),
29
30 /// An invalid combination of ranges ([a-b-c]) within a character class.
31 #[error("Range following a {0:?}-{1:?} range")]
32 RangeAfterRange(char, char),
33
34 /// A reversed range within a character class.
35 #[error("Reversed range from {0:?} to {1:?}")]
36 ReversedRange(char, char),
37
38 /// An alternation that was not closed before the end of the pattern.
39 #[error("Unclosed alternation")]
40 UnclosedAlternation,
41
42 /// A character class that was not closed before the end of the pattern.
43 #[error("Unclosed character class")]
44 UnclosedClass,
45}