Skip to content

Commit

Permalink
Show details when a regex fails to compile (GH-2678)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Dec 8, 2021
1 parent 085efac commit e7ddf52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
@@ -1,5 +1,11 @@
# Change Log

## Unreleased

### _Black_

- Improve error message for invalid regular expression (#2678)

## 21.12b0

### _Black_
Expand Down
4 changes: 2 additions & 2 deletions src/black/__init__.py
Expand Up @@ -177,8 +177,8 @@ def validate_regex(
) -> Optional[Pattern[str]]:
try:
return re_compile_maybe_verbose(value) if value is not None else None
except re.error:
raise click.BadParameter("Not a valid regular expression") from None
except re.error as e:
raise click.BadParameter(f"Not a valid regular expression: {e}") from None


@click.command(
Expand Down

0 comments on commit e7ddf52

Please sign in to comment.