From: Jelle Zijlstra Date: Wed, 8 Dec 2021 03:13:05 +0000 (-0800) Subject: Show details when a regex fails to compile (GH-2678) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/e7ddf524b056d2bc42ee6b2b5c3314e0dd5d95fb?ds=sidebyside Show details when a regex fails to compile (GH-2678) --- diff --git a/CHANGES.md b/CHANGES.md index 9e13ef4..3724820 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Change Log +## Unreleased + +### _Black_ + +- Improve error message for invalid regular expression (#2678) + ## 21.12b0 ### _Black_ diff --git a/src/black/__init__.py b/src/black/__init__.py index 1923c06..e2376c4 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -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(