Current section
Files
Jump to
Current section
Files
src/cigogne@types.erl
-module(cigogne@types).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([print_migrate_error/1]).
-export_type([migrate_error/0, migration/0]).
-type migrate_error() :: {env_var_error, binary()} |
{url_error, binary()} |
{file_error, binary()} |
{pattern_error, binary()} |
{file_name_error, binary()} |
{compound_error, list(migrate_error())} |
{content_error, binary(), binary()} |
{pgo_transaction_error, pog:transaction_error()} |
{pgo_query_error, pog:query_error()} |
no_result_error |
{schema_query_error, binary()} |
no_migration_to_apply_error |
no_migration_to_rollback_error |
{migration_not_found_error, tempo:naive_date_time(), binary()} |
{date_parse_error, binary()}.
-type migration() :: {migration,
binary(),
tempo:naive_date_time(),
binary(),
list(binary()),
list(binary())}.
-file("/home/runner/work/cigogne/cigogne/src/cigogne/types.gleam", 40).
-spec print_migrate_error(migrate_error()) -> nil.
print_migrate_error(Error) ->
case Error of
{compound_error, Suberrors} ->
gleam_stdlib:println_error(<<"["/utf8>>),
gleam@list:each(Suberrors, fun print_migrate_error/1),
gleam_stdlib:println_error(<<"]"/utf8>>);
{content_error, Path, Message} ->
gleam_stdlib:println_error(
<<<<<<<<"At ["/utf8, Path/binary>>/binary,
"]: Content wasn't right <"/utf8>>/binary,
Message/binary>>/binary,
">"/utf8>>
);
{env_var_error, Name} ->
gleam_stdlib:println_error(
<<"Couldn't find env var "/utf8, Name/binary>>
);
{file_error, Path@1} ->
gleam_stdlib:println_error(
<<<<"Couldn't access file at path ["/utf8, Path@1/binary>>/binary,
"]"/utf8>>
);
{file_name_error, Path@2} ->
gleam_stdlib:println_error(
<<<<"Migration filenames should have the format <MigrationNumber>-<MigrationName>.sql ! Got: ["/utf8,
Path@2/binary>>/binary,
"]"/utf8>>
);
no_result_error ->
gleam_stdlib:println_error(
<<"Got no result from DB (can't get last applied migration)"/utf8>>
);
{pgo_query_error, Suberror} ->
gleam_stdlib:println_error(
cigogne@internal@utils:describe_query_error(Suberror)
);
{pgo_transaction_error, Suberror@1} ->
gleam_stdlib:println_error(
cigogne@internal@utils:describe_transaction_error(Suberror@1)
);
{pattern_error, Message@1} ->
gleam_stdlib:println_error(Message@1);
{url_error, Url} ->
gleam_stdlib:println_error(
<<"Database URL badly formatted: "/utf8, Url/binary>>
);
{schema_query_error, Err} ->
gleam_stdlib:println_error(
<<"Error while querying schema : "/utf8, Err/binary>>
);
no_migration_to_apply_error ->
gleam_stdlib:println_error(<<"No migration to apply !"/utf8>>);
no_migration_to_rollback_error ->
gleam_stdlib:println_error(<<"No migration to rollback !"/utf8>>);
{migration_not_found_error, Ts, Name@1} ->
gleam_stdlib:println_error(
<<<<<<<<"Migration not found [timestamp: "/utf8,
(begin
_pipe = Ts,
tempo@naive_datetime:to_string(_pipe)
end)/binary>>/binary,
", name: "/utf8>>/binary,
Name@1/binary>>/binary,
"]"/utf8>>
);
{date_parse_error, Date} ->
gleam_stdlib:println_error(
<<"Date couldn't be properly parsed: "/utf8, Date/binary>>
)
end.