Skip to content

Introduce GqlError.find_by_gql_status - #1216

Merged
robsdedude merged 3 commits into
neo4j:6.xfrom
robsdedude:feat/gql-error-cause-chain-helper
Jul 15, 2025
Merged

Introduce GqlError.find_by_gql_status#1216
robsdedude merged 3 commits into
neo4j:6.xfrom
robsdedude:feat/gql-error-cause-chain-helper

Conversation

@robsdedude

Copy link
Copy Markdown
Member

Return the first GqlError in the cause chain with the given GQL status.

This method traverses this GQLErorrs's :attr:__cause__ chain, starting with this error itself, and returns the first error that has the given GQL status. If no error matches, :data:None is returned.

Example:

def invalid_syntax(err: GqlError) -> bool:
    return err.find_by_gql_status("42001") is not None

@robsdedude
robsdedude force-pushed the feat/gql-error-cause-chain-helper branch 3 times, most recently from 6c0bad6 to a75fad3 Compare July 14, 2025 08:14
Return the first GqlError in the cause chain with the given GQL status.

This method traverses this GQLErorrs's :attr:`__cause__` chain,
starting with this error itself, and returns the first error that has
the given GQL status. If no error matches, :data:`None` is returned.

Example:

```python
def invalid_syntax(err: GqlError) -> bool:
    return err.find_by_gql_status("42001") is not None
```
@robsdedude
robsdedude force-pushed the feat/gql-error-cause-chain-helper branch from a75fad3 to 89a66b6 Compare July 14, 2025 08:20
Comment thread src/neo4j/exceptions.py Outdated
@robsdedude
robsdedude marked this pull request as ready for review July 14, 2025 10:32
Comment thread tests/unit/common/test_exceptions.py Outdated
@robsdedude
robsdedude force-pushed the feat/gql-error-cause-chain-helper branch from c0c6f66 to 6b8424a Compare July 15, 2025 09:53

@MaxAake MaxAake left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔎 ✅

@robsdedude
robsdedude merged commit 9d0cec6 into neo4j:6.x Jul 15, 2025
@robsdedude
robsdedude deleted the feat/gql-error-cause-chain-helper branch July 15, 2025 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants