or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

asgi.mdcore-schema.mderror-handling.mdexecution.mdexplorer.mdfederation.mdfile-uploads.mdindex.mdrelay.mdresolvers.mdtype-bindables.mdvalidation.md

error-handling.mddocs/

0

# Error Handling

1

2

Functions for formatting GraphQL errors and extracting error information for client responses.

3

4

## Capabilities

5

6

### Error Formatting

7

8

```python { .api }

9

def format_error(error: Exception, debug: bool = False) -> dict:

10

"""

11

Format GraphQL error for client response.

12

13

Parameters:

14

- error: Exception to format

15

- debug: Include debug information

16

17

Returns:

18

Formatted error dict with message, locations, path

19

"""

20

21

def get_error_extension(error: Exception) -> Optional[dict]:

22

"""Extract extension data from error."""

23

24

def get_formatted_error_context(error: dict) -> Optional[Any]:

25

"""Get context information from formatted error."""

26

27

def get_formatted_error_traceback(error: dict) -> Optional[str]:

28

"""Get traceback from formatted error."""

29

30

def unwrap_graphql_error(error: Exception) -> Exception:

31

"""Unwrap GraphQL error to get original exception."""

32

```

33

34

## Usage Examples

35

36

```python

37

from ariadne import format_error

38

39

# Custom error formatting

40

def custom_error_formatter(error, debug=False):

41

formatted = format_error(error, debug)

42

formatted["timestamp"] = datetime.now().isoformat()

43

return formatted

44

```