-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([to_string/1, 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()} | {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()} | {type_alias_not_supported, binary(), binary()}. -file("src/libero/gen_error.gleam", 118). -spec format_file_error(simplifile:file_error()) -> binary(). format_file_error(Err) -> simplifile:describe_error(Err). -file("src/libero/gen_error.gleam", 27). -spec to_string(gen_error()) -> binary(). to_string(Err) -> case Err of {cannot_read_dir, Path, Cause} -> <<<<<<"error: Cannot read directory \x{250c}\x{2500} "/utf8, Path/binary>>/binary, " \x{2502} \x{2502} "/utf8>>/binary, (format_file_error(Cause))/binary>>; {cannot_read_file, Path@1, Cause@1} -> <<<<<<"error: Cannot read file \x{250c}\x{2500} "/utf8, Path@1/binary>>/binary, " \x{2502} \x{2502} "/utf8>>/binary, (format_file_error(Cause@1))/binary>>; {cannot_write_file, Path@2, Cause@2} -> <<<<<<<<"error: Cannot write file \x{250c}\x{2500} "/utf8, Path@2/binary>>/binary, " \x{2502} \x{2502} "/utf8>>/binary, (format_file_error(Cause@2))/binary>>/binary, " \x{2502} hint: Check that the directory exists and you have write permission"/utf8>>; {parse_failed, Path@3, _} -> <<<<"error: Failed to parse Gleam source \x{250c}\x{2500} "/utf8, Path@3/binary>>/binary, " \x{2502} \x{2502} glance could not parse this file as valid Gleam \x{2502} hint: Run `gleam check` to see the full compiler error"/utf8>>; {unresolved_type_module, Module_path, Type_name} -> <<<<<<<<<<<<"error: Unresolved type module \x{250c}\x{2500} "/utf8, Module_path/binary>>/binary, " \x{2502} \x{2502} Type `"/utf8>>/binary, Type_name/binary>>/binary, "` could not be resolved to a file path \x{2502} hint: Ensure the module is a path dependency of the client package. Check that `"/utf8>>/binary, Module_path/binary>>/binary, "` appears in the shared/ directory or is listed as a dependency in gleam.toml"/utf8>>; {type_not_found, Module_path@1, Type_name@1} -> <<<<<<<<"error: Type not found \x{250c}\x{2500} "/utf8, Module_path@1/binary>>/binary, ".gleam \x{2502} \x{2502} Type `"/utf8>>/binary, Type_name@1/binary>>/binary, "` was not found in this module \x{2502} hint: The type may be private (add `pub`) or the module path may be incorrect. Libero scans for custom types, not type aliases."/utf8>>; {msg_from_server_field_count, Module_path@2, Variant_name, Field_count} -> <<<<<<<<<<<<<<<<"error: Too many fields on MsgFromServer variant \x{250c}\x{2500} "/utf8, Module_path@2/binary>>/binary, ".gleam \x{2502} \x{2502} `"/utf8>>/binary, Variant_name/binary>>/binary, "` has "/utf8>>/binary, (erlang:integer_to_binary(Field_count))/binary>>/binary, " fields, but MsgFromServer variants must have 0 or 1 \x{2502} hint: Wrap multiple values in a single type: pub type MsgFromServer { "/utf8>>/binary, Variant_name/binary>>/binary, "(MyPayload) \x{2190} one field } pub type MyPayload { MyPayload(field_a: Int, field_b: String) }"/utf8>>; {missing_handler, Message_module, Expected} -> <<<<<<<<<<<<<<<<"error: Missing handler module \x{250c}\x{2500} "/utf8, Expected/binary>>/binary, ".gleam \x{2502} \x{2502} Message module `"/utf8>>/binary, Message_module/binary>>/binary, "` has MsgFromClient \x{2502} but no handler was found at `"/utf8>>/binary, Expected/binary>>/binary, "` \x{2502} hint: Create the handler module: // "/utf8>>/binary, Expected/binary>>/binary, ".gleam pub fn update_from_client( msg msg: MsgFromClient, state state: SharedState, ) -> Result(#(MsgFromServer, SharedState), AppError)"/utf8>>; {no_message_modules, Shared_path} -> <<<<<<<<"error: No message modules found \x{250c}\x{2500} "/utf8, Shared_path/binary>>/binary, "/ \x{2502} \x{2502} Libero scans this directory for types named \x{2502} `MsgFromClient` or `MsgFromServer`, but found none \x{2502} hint: Create a shared message module: // "/utf8>>/binary, Shared_path/binary>>/binary, "/messages.gleam pub type MsgFromClient { Ping } pub type MsgFromServer { Pong }"/utf8>>; {type_alias_not_supported, Module_path@3, Type_name@2} -> <<<<<<<<"error: Type alias not supported \x{250c}\x{2500} "/utf8, Module_path@3/binary>>/binary, " \x{2502} \x{2502} \""/utf8>>/binary, Type_name@2/binary>>/binary, "\" is a type alias. Libero cannot walk type aliases \x{2502} transitively \x{2014} their underlying type won't be registered for decoding. \x{2502} hint: Reference the underlying custom type directly in your message fields"/utf8>> end. -file("src/libero/gen_error.gleam", 23). -spec print_error(gen_error()) -> nil. print_error(Err) -> gleam_stdlib:println_error(to_string(Err)).