CalDAVEx.Error (CalDAVEx v0.2.1)

Copy Markdown View Source

Error types and utilities for CalDAV operations.

All CalDAVEx functions return errors as {:error, %CalDAVEx.Error{}}.

Summary

Types

t()

Error struct.

Functions

Creates a conflict error (HTTP 409)

Creates an HTTP error with status code and response body

Creates an invalid-argument error (caller-side validation failure)

Creates a not found error (HTTP 404)

Creates a CalDAV protocol error

Converts an error to a human-readable string.

Creates a transport error (network/connection issues)

Creates an unauthorized error (HTTP 401)

Creates an XML parsing error

Types

t()

@type t() :: %CalDAVEx.Error{
  details: term() | nil,
  message: String.t() | nil,
  type: type()
}

type()

@type type() ::
  :transport
  | :http
  | :xml
  | :protocol
  | :not_found
  | :unauthorized
  | :conflict
  | :invalid_argument

Error struct.

Fields

  • type - The error type (:transport, :http, :xml, :protocol, :not_found, :unauthorized, :conflict, :invalid_argument)
  • message - Human-readable error message
  • details - Additional error details (optional)

Functions

conflict()

@spec conflict() :: t()

Creates a conflict error (HTTP 409)

http(status, body)

@spec http(integer(), term()) :: t()

Creates an HTTP error with status code and response body

invalid_argument(msg)

@spec invalid_argument(String.t()) :: t()

Creates an invalid-argument error (caller-side validation failure)

not_found()

@spec not_found() :: t()

Creates a not found error (HTTP 404)

protocol(msg)

@spec protocol(String.t()) :: t()

Creates a CalDAV protocol error

to_string(e)

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

Converts an error to a human-readable string.

Examples

error = CalDAVEx.Error.http(404, "Not found")
CalDAVEx.Error.to_string(error)
# => "[caldav_ex] HTTP error: HTTP 404 - Not found"

transport(msg)

@spec transport(String.t()) :: t()

Creates a transport error (network/connection issues)

unauthorized()

@spec unauthorized() :: t()

Creates an unauthorized error (HTTP 401)

xml(msg)

@spec xml(String.t()) :: t()

Creates an XML parsing error