Packages

A lightweight Gleam CalDAV client library for discovery, calendars, and events.

Current section

Files

Jump to
caldav_gleam src caldav@error.erl
Raw

src/caldav@error.erl

-module(caldav@error).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src\\caldav\\error.gleam").
-export([to_string/1]).
-export_type([error/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-type error() :: {transport_error, binary()} |
{http_error, integer(), binary()} |
{xml_error, binary()} |
{protocol_error, binary()} |
not_found |
unauthorized |
conflict |
{validation_error, binary()} |
unknown_error.
-file("src\\caldav\\error.gleam", 17).
?DOC(" Renders an error as a readable string.\n").
-spec to_string(error()) -> binary().
to_string(Err) ->
case Err of
{transport_error, Message} ->
<<"[caldav_gleam] Transport error: "/utf8, Message/binary>>;
{http_error, Status, Body} ->
<<<<<<<<"[caldav_gleam] HTTP Error. Status: "/utf8,
(erlang:integer_to_binary(Status))/binary>>/binary,
" "/utf8>>/binary,
"Body: "/utf8>>/binary,
Body/binary>>;
{xml_error, Message@1} ->
<<"[caldav_gleam] XML Error: "/utf8, Message@1/binary>>;
{protocol_error, Message@2} ->
<<"[caldav_gleam] Protocol Error: "/utf8, Message@2/binary>>;
not_found ->
<<"[caldav_gleam] Not found error"/utf8>>;
unauthorized ->
<<"[caldav_gleam] Unauthorized error"/utf8>>;
conflict ->
<<"[caldav_gleam] Conflict Error"/utf8>>;
{validation_error, Message@3} ->
<<"[caldav_gleam] Validation Error: "/utf8, Message@3/binary>>;
unknown_error ->
<<"[caldav_gleam] Unknown error"/utf8>>
end.