Error codes

The following list shows the possible Fauna error codes returned in an error response. The list isn’t exhaustive.

Errors should be handled, first, based on the Fauna error code. If the response includes an error code not shown in the following list, the error should be handled according to the HTTP status code.

Error responses tend to be self-explanatory and include a detailed description of the error, including the location in the query string where the error is detected, if applicable.

Error code list

abort

constraint_failure

constraint_violation

contended_transaction

divide_by_zero

document_already_exists

document_not_found

forbidden

index_out_of_bounds

internal_error

internal_failure

invalid_argument

invalid_bounds

invalid_cursor

invalid_date

invalid_document_id

invalid_effect

invalid_function_invocation

invalid_index_invocation

invalid_null_access

invalid_regex

invalid_request

invalid_schema

invalid_time

invalid_type

invalid_unit

invalid_write

limit_exceeded

null_value

permission_denied

request_size_exceeded

stack_overflow

time_out

tmp_write_failed

type_mismatch

unauthorized

Example error responses

The message part of the error response is descriptive and formatted, indicating the location in the expression or statement where the error occurred, if applicable.

Simple response

{
    "error": {
        "code": "invalid_function_invocation",
        "message": "The function `al` doesn't exist on `Collection`"
    },
    ... elided ...
}

Formatted response with error location

{
    "error": {
        "code": "invalid_query",
        "message": "The query failed 1 validation check"
    },
    "summary": "error: Missing return expression\nat *query*:1:13\n  |\n1 | let x = true\n  |             ^\n  |\ncause: Statement doesn't return a value\n  |\n1 | let x = true\n  | ^^^^^^^^^^^^\n  |",
    ... elided ...
}

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!