View Source Appwrite.Exceptions.AppwriteException exception (appwrite v0.1.7)

Represents an exception in the Appwrite library.

This exception is raised when errors occur during API calls, such as invalid responses or request failures.

Summary

Functions

Converts the exception into a readable string format.

Types

@type t() :: %Appwrite.Exceptions.AppwriteException{
  __exception__: true,
  code: non_neg_integer(),
  message: String.t(),
  response: any(),
  type: String.t()
}

Functions

Link to this function

new(message \\ "An error occurred", code \\ 0, type \\ "", response \\ nil)

View Source
@spec new(String.t(), non_neg_integer(), String.t(), any()) :: t()

Creates a new Appwrite.Exception struct.

Parameters

  • message - The error message (default: "An error occurred").
  • code - The error code (default: 0).
  • type - The type of the error (default: an empty string).
  • response - Additional response data (default: nil).

Examples

iex> Appwrite.Exception.new("Unauthorized access", 401, "auth_error", %{"details" => "Invalid token"})
%Appwrite.Exception{
  message: "Unauthorized access",
  code: 401,
  type: "auth_error",
  response: %{"details" => "Invalid token"}
}
Link to this function

to_string(appwrite_exception)

View Source
@spec to_string(t()) :: String.t()

Converts the exception into a readable string format.

Examples

iex> exception = Appwrite.Exception.new("Not found", 404, "not_found", %{})
iex> Appwrite.Exception.to_string(exception)
"[404] not_found: Not found"