Current section

Files

Jump to
parrot src parrot@internal@errors.erl
Raw

src/parrot@internal@errors.erl

-module(parrot@internal@errors).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-define(FILEPATH, "src/parrot/internal/errors.gleam").
-export([err_to_string/1]).
-export_type([parrot_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.
?MODULEDOC(false).
-type parrot_error() :: {unknown_engine, binary()} |
{sqlite_d_b_not_found, binary()} |
{my_sql_d_b_not_found, binary()} |
{postgre_sql_d_b_not_found, binary()} |
{sqlc_download_error, binary()} |
{sqlc_generate_error, binary()} |
{gleam_format_error, binary()} |
no_queries_found |
mysqldump_error |
pgdump_error |
codegen_error.
-file("src/parrot/internal/errors.gleam", 20).
?DOC(false).
-spec err_to_string(parrot_error()) -> binary().
err_to_string(Error) ->
case Error of
{my_sql_d_b_not_found, _} ->
<<"mysql db not found"/utf8>>;
{postgre_sql_d_b_not_found, _} ->
<<"postgresql db not found"/utf8>>;
{sqlite_d_b_not_found, _} ->
<<"sqlite db not found"/utf8>>;
mysqldump_error ->
<<"there was an error with mysqldump"/utf8>>;
{sqlc_download_error, E} ->
<<"there was an error downloading sqlc: "/utf8, E/binary>>;
{sqlc_generate_error, E@1} ->
<<"could not call `sqlc generate`:\n"/utf8, E@1/binary>>;
pgdump_error ->
<<"there was an error pg_dump"/utf8>>;
no_queries_found ->
<<"no queries were found to codegen"/utf8>>;
{unknown_engine, Engine} ->
<<"unknown engine: "/utf8, Engine/binary>>;
codegen_error ->
<<"there was an error during codegen"/utf8>>;
{gleam_format_error, Err} ->
<<"there was an error formatting the generated code:"/utf8,
Err/binary>>
end.