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:
konsti 2023-07-19 17:15:26 +02:00 committed by GitHub
parent 46a17d11f3
commit 63ed7a31e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 13 deletions

View file

@ -20,7 +20,9 @@ impl FormatNodeRule<StmtAssign> for FormatStmtAssign {
type_comment: _,
} = item;
let (first, rest) = targets.split_first().ok_or(FormatError::SyntaxError)?;
let (first, rest) = targets.split_first().ok_or(FormatError::syntax_error(
"Expected at least on assignment target",
))?;
write!(
f,