Skip to content

Commit

Permalink
doc: add more explanation to 'CompiledTooBig' error
Browse files Browse the repository at this point in the history
The existing docs were pretty paltry, and it turns out we can be a bit
more helpful for folks when they hit this error.

Fixes #846
  • Loading branch information
BurntSushi committed Apr 17, 2023
1 parent e65ba17 commit d04ea10
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,26 @@ use std::iter::repeat;
pub enum Error {
/// A syntax error.
Syntax(String),
/// The compiled program exceeded the set size limit.
/// The argument is the size limit imposed.
/// The compiled program exceeded the set size
/// limit. The argument is the size limit imposed by
/// [`RegexBuilder::size_limit`](crate::RegexBuilder::size_limit). Even
/// when not configured explicitly, it defaults to a reasonable limit.
///
/// If you're getting this error, it occurred because your regex has been
/// compiled to an intermediate state that is too big. It is important to
/// note that exceeding this limit does _not_ mean the regex is too big to
/// _work_, but rather, the regex is big enough that it may wind up being
/// surprisingly slow when used in a search. In other words, this error is
/// meant to be a practical heuristic for avoiding a performance footgun,
/// and especially so for the case where the regex pattern is coming from
/// an untrusted source.
///
/// There are generally two ways to move forward if you hit this error.
/// The first is to find some way to use a smaller regex. The second is to
/// increase the size limit via `RegexBuilder::size_limit`. However, if
/// your regex pattern is not from a trusted source, then neither of these
/// approaches may be appropriate. Instead, you'll have to determine just
/// how big of a regex you want to allow.
CompiledTooBig(usize),
/// Hints that destructuring should not be exhaustive.
///
Expand Down

0 comments on commit d04ea10

Please sign in to comment.