The single exception type raised (or returned) by every TypeDB operation.
Errors carry a :kind describing where the failure came from:
:server— TypeDB answered with a structured error body.:codeholds the TypeDB error code (e.g."TSV11","AUT3","HSR4"),:statusthe HTTP status, and:messagethe server's message, including its cause trace.:transport— the request never produced an HTTP response (connection refused, DNS failure, TLS failure, socket closed).:timeout— the request exceeded the configured timeout.:unauthenticated— credentials were rejected, or the token expired and could not be renewed.:decode— the response body was not valid JSON, or did not match the shape this driver expects.:config— the driver was configured incorrectly. Raised at start-up.
Matching on TypeDB error codes
case TypeDB.query(conn, "social", "match $x isa nonexistent;") do
{:error, %TypeDB.Error{kind: :server, code: code}} -> {:bad_query, code}
{:ok, answer} -> answer
endError codes are stable across TypeDB releases and are the recommended thing to branch on; messages are not.
Summary
Types
Functions
@spec from_response(pos_integer(), term()) :: t()
Builds an error from a TypeDB error response body.
TypeDB error bodies are %{"code" => code, "message" => message}. Anything
else is reported verbatim so that no information is lost.
Builds an error.
Public because TypeDB.HTTP is a public extension point and TypeDB.HTTP.request/6
is required to return one of these. Application code should be matching on
errors, not constructing them.
TypeDB.Error.new(:transport, "connection refused", reason: :econnrefused)Options
:code— TypeDB's own error code, for:servererrors:status— the HTTP status:reason— the underlying term, whatever it was:body— the response body that could not be understood