1// SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
2// SPDX-License-Identifier: BSD-2-Clause
3//! Common error definitions for the fnmatch crate.
45use anyhow::Error as AnyError;
6use regex::Error as RexError;
7use thiserror::Error;
89/// 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")]
16BareEscape,
1718/// Something went really, really wrong.
19#[error("fnmatch-regex internal error")]
20InternalError(#[source] AnyError),
2122/// The resulting regex was invalid.
23#[error("Could not compile the resulting pattern {0:?}")]
24InvalidRegex(String, #[source] RexError),
2526/// Some known missing functionality.
27#[error("Not implemented yet: {0}")]
28NotImplemented(String),
2930/// An invalid combination of ranges ([a-b-c]) within a character class.
31#[error("Range following a {0:?}-{1:?} range")]
32RangeAfterRange(char, char),
3334/// A reversed range within a character class.
35#[error("Reversed range from {0:?} to {1:?}")]
36ReversedRange(char, char),
3738/// An alternation that was not closed before the end of the pattern.
39#[error("Unclosed alternation")]
40UnclosedAlternation,
4142/// A character class that was not closed before the end of the pattern.
43#[error("Unclosed character class")]
44UnclosedClass,
45}