mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Add message to formatter SyntaxError (#5881)
**Summary** Add a static string error message to the formatter syntax error so we can disambiguate where the syntax error came from **Test Plan** No fixed tests, we don't expect this to occur, but it helped with transformers syntax error debugging: ``` Error: Failed to format node Caused by: syntax error: slice first colon token was not a colon ```
This commit is contained in:
parent
46a17d11f3
commit
63ed7a31e8
6 changed files with 38 additions and 13 deletions
|
@ -251,7 +251,9 @@ impl Format<PyFormatContext<'_>> for FormatComment<'_> {
|
|||
let trailing_whitespace_len = comment_text.text_len() - trimmed.text_len();
|
||||
|
||||
let Some(content) = trimmed.strip_prefix('#') else {
|
||||
return Err(FormatError::SyntaxError);
|
||||
return Err(FormatError::syntax_error(
|
||||
"Didn't find expected comment token `#`",
|
||||
));
|
||||
};
|
||||
|
||||
// Fast path for correctly formatted comments:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue