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()} |
{migration_not_found_error, integer()} |
no_result_error |
{schema_query_error, binary()} |
no_migration_to_apply_error.
-type migration() :: {migration,
binary(),
integer(),
binary(),
list(binary()),
list(binary())}.
-file("/home/runner/work/cigogne/cigogne/src/cigogne/types.gleam", 37).
-spec print_migrate_error(migrate_error()) -> nil.
print_migrate_error(Error) ->
case Error of
{compound_error, Suberrors} ->
gleam@io:println_error(<<"["/utf8>>),
gleam@list:each(Suberrors, fun print_migrate_error/1),
gleam@io:println_error(<<"]"/utf8>>);
{content_error, Path, Message} ->
gleam@io:println_error(
<<<<<<<<"At ["/utf8, Path/binary>>/binary,
"]: Content wasn't right <"/utf8>>/binary,
Message/binary>>/binary,
">"/utf8>>
);
{env_var_error, Name} ->
gleam@io:println_error(
<<"Couldn't find env var "/utf8, Name/binary>>
);
{file_error, Path@1} ->
gleam@io:println_error(
<<<<"Couldn't access file at path ["/utf8, Path@1/binary>>/binary,
"]"/utf8>>
);
{file_name_error, Path@2} ->
gleam@io:println_error(
<<<<"Migration filenames should have the format <MigrationNumber>-<MigrationName>.sql ! Got: ["/utf8,
Path@2/binary>>/binary,
"]"/utf8>>
);
{migration_not_found_error, 0} ->
gleam@io:println_error(
<<"Migration n°0 cannot be fetched or rolled back"/utf8>>
);
{migration_not_found_error, Number} ->
gleam@io:println_error(
<<<<"Migration n°"/utf8, (gleam@int:to_string(Number))/binary>>/binary,
" does not exist !"/utf8>>
);
no_result_error ->
gleam@io:println_error(
<<"Got no result from DB (can't get last applied migration)"/utf8>>
);
{pgo_query_error, Suberror} ->
gleam@io:println_error(
cigogne@internal@utils:describe_query_error(Suberror)
);
{pgo_transaction_error, Suberror@1} ->
gleam@io:println_error(
cigogne@internal@utils:describe_transaction_error(Suberror@1)
);
{pattern_error, Message@1} ->
gleam@io:println_error(Message@1);
{url_error, Url} ->
gleam@io:println_error(
<<"Database URL badly formatted: "/utf8, Url/binary>>
);
{schema_query_error, Err} ->
gleam@io:println_error(
<<"Error while querying schema : "/utf8, Err/binary>>
);
no_migration_to_apply_error ->
gleam@io:println_error(<<"No migration to apply !"/utf8>>)
end.