Current section
Files
Jump to
Current section
Files
src/libero@gen_error.erl
-module(libero@gen_error).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/libero/gen_error.gleam").
-export([print_error/1]).
-export_type([gen_error/0]).
-type gen_error() :: {cannot_read_dir, binary(), simplifile:file_error()} |
{cannot_read_file, binary(), simplifile:file_error()} |
{cannot_write_file, binary(), simplifile:file_error()} |
{parse_failed, binary(), glance:error()} |
{empty_module_path, binary()} |
{unresolved_type_module, binary(), binary()} |
{type_not_found, binary(), binary()} |
{missing_handler, binary(), binary()} |
{msg_from_server_field_count, binary(), binary(), integer()} |
{no_message_modules, binary()}.
-file("src/libero/gen_error.gleam", 77).
-spec format_file_error(simplifile:file_error()) -> binary().
format_file_error(Err) ->
simplifile:describe_error(Err).
-file("src/libero/gen_error.gleam", 23).
-spec print_error(gen_error()) -> nil.
print_error(Err) ->
Message = case Err of
{cannot_read_dir, Path, Cause} ->
<<<<<<<<"cannot read directory: "/utf8, Path/binary>>/binary,
" ("/utf8>>/binary,
(format_file_error(Cause))/binary>>/binary,
")"/utf8>>;
{cannot_read_file, Path@1, Cause@1} ->
<<<<<<<<"cannot read file: "/utf8, Path@1/binary>>/binary,
" ("/utf8>>/binary,
(format_file_error(Cause@1))/binary>>/binary,
")"/utf8>>;
{cannot_write_file, Path@2, Cause@2} ->
<<<<<<<<"cannot write file: "/utf8, Path@2/binary>>/binary,
" ("/utf8>>/binary,
(format_file_error(Cause@2))/binary>>/binary,
")"/utf8>>;
{parse_failed, Path@3, _} ->
<<Path@3/binary,
": failed to parse as Gleam source (glance.module error)"/utf8>>;
{empty_module_path, Path@4} ->
<<Path@4/binary,
": could not derive module segments (path produced empty list)"/utf8>>;
{unresolved_type_module, Module_path, Type_name} ->
<<<<<<<<<<"type `"/utf8, Type_name/binary>>/binary,
"` from module `"/utf8>>/binary,
Module_path/binary>>/binary,
"` could not be resolved to a file path"/utf8>>/binary,
"\n ensure the module is in a path dep of the client package"/utf8>>;
{type_not_found, Module_path@1, Type_name@1} ->
<<<<<<<<<<"type `"/utf8, Type_name@1/binary>>/binary,
"` was not found in module `"/utf8>>/binary,
Module_path@1/binary>>/binary,
"`"/utf8>>/binary,
"\n the type may be private, or the module path may be incorrect"/utf8>>;
{msg_from_server_field_count, Module_path@2, Variant_name, Field_count} ->
<<<<<<<<<<<<<<"MsgFromServer variant `"/utf8, Variant_name/binary>>/binary,
"` in `"/utf8>>/binary,
Module_path@2/binary>>/binary,
"` has "/utf8>>/binary,
(erlang:integer_to_binary(Field_count))/binary>>/binary,
" fields, expected 0 or 1"/utf8>>/binary,
"\n dispatch unwraps the envelope with element(2, Tuple), which drops extra fields"/utf8>>;
{missing_handler, Message_module, Expected} ->
<<<<<<<<"missing handler for message module `"/utf8,
Message_module/binary>>/binary,
"`: expected "/utf8>>/binary,
Expected/binary>>/binary,
"\n create a server module exporting `pub fn update_from_client` with the correct type annotation"/utf8>>;
{no_message_modules, Shared_path} ->
<<<<<<"no message modules found under `"/utf8, Shared_path/binary>>/binary,
"`"/utf8>>/binary,
"\n create a shared module exporting a `MsgFromClient` or `MsgFromServer` type"/utf8>>
end,
gleam_stdlib:println_error(<<"error: "/utf8, Message/binary>>).