View Source Appwrite.Exceptions.AppwriteException exception (appwrite v0.1.9)
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
Creates a new Appwrite.Exception
struct.
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
@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"}
}
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"