-module(eensy_dev_tools@error). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([explain/1]). -export_type([error/0]). -type error() :: {build_error, binary()} | {bundle_error, binary()} | {cannot_create_directory, simplifile:file_error(), binary()} | {cannot_read_file, simplifile:file_error(), binary()}. -file("src/eensy_dev_tools/error.gleam", 29). -spec build_error(binary()) -> binary(). build_error(Reason) -> Message = <<" It looks like your project has some compilation errors that need to be addressed before I can do anything. Here's the error message I got: {reason} "/utf8>>, _pipe = Message, gleam@string:replace(_pipe, <<"{reason}"/utf8>>, Reason). -file("src/eensy_dev_tools/error.gleam", 42). -spec bundle_error(binary()) -> binary(). bundle_error(Reason) -> Message = <<" I ran into an unexpected issue while trying to bundle your project with esbuild. Here's the error message I got: {reason} If you think this is a bug, please open an issue with some details about what you were trying to do when you ran into this issue. "/utf8>>, _pipe = Message, gleam@string:replace(_pipe, <<"{reason}"/utf8>>, Reason). -file("src/eensy_dev_tools/error.gleam", 58). -spec cannot_create_directory(simplifile:file_error(), binary()) -> binary(). cannot_create_directory(Reason, Path) -> Message = <<" I ran into an error while trying to create the following directory: {path} Here's the error message I got: {reason} If you think this is a bug, please open an issue with some details about what you were trying to do when you ran into this issue. "/utf8>>, _pipe = Message, _pipe@1 = gleam@string:replace(_pipe, <<"{path}"/utf8>>, Path), gleam@string:replace( _pipe@1, <<"{reason}"/utf8>>, gleam@string:inspect(Reason) ). -file("src/eensy_dev_tools/error.gleam", 78). -spec cannot_read_file(simplifile:file_error(), binary()) -> binary(). cannot_read_file(Reason, Path) -> Message = <<" I ran into an error while trying to read the following file: {path} Here's the error message I got: {reason} If you think this is a bug, please open an issue with some details about what you were trying to do when you ran into this issue. "/utf8>>, _pipe = Message, _pipe@1 = gleam@string:replace(_pipe, <<"{path}"/utf8>>, Path), gleam@string:replace( _pipe@1, <<"{reason}"/utf8>>, gleam@string:inspect(Reason) ). -file("src/eensy_dev_tools/error.gleam", 20). -spec explain(error()) -> binary(). explain(Error) -> case Error of {build_error, Reason} -> build_error(Reason); {bundle_error, Reason@1} -> bundle_error(Reason@1); {cannot_create_directory, Reason@2, Path} -> cannot_create_directory(Reason@2, Path); {cannot_read_file, Reason@3, Path@1} -> cannot_read_file(Reason@3, Path@1) end. -file("src/eensy_dev_tools/error.gleam", 134). -spec pretty_var(integer()) -> binary(). pretty_var(Id) -> case Id >= 26 of true -> <<(pretty_var((Id div 26) - 1))/binary, (pretty_var(Id rem 26))/binary>>; false -> Id@1 = Id + 97, _assert_subject = gleam@bit_array:to_string(<>), {ok, Var} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail, module => <<"eensy_dev_tools/error"/utf8>>, function => <<"pretty_var"/utf8>>, line => 140}) end, Var end. -file("src/eensy_dev_tools/error.gleam", 100). -spec pretty_type(gleam@package_interface:type()) -> binary(). pretty_type(T) -> case T of {tuple, Elements} -> Message = <<"#({elements})"/utf8>>, Elements@1 = gleam@list:map(Elements, fun pretty_type/1), _pipe = Message, gleam@string:replace( _pipe, <<"{elements}"/utf8>>, gleam@string:join(Elements@1, <<", "/utf8>>) ); {fn, Params, Return} -> Message@1 = <<"fn({params}) -> {return}"/utf8>>, Params@1 = gleam@list:map(Params, fun pretty_type/1), Return@1 = pretty_type(Return), _pipe@1 = Message@1, _pipe@2 = gleam@string:replace( _pipe@1, <<"{params}"/utf8>>, gleam@string:join(Params@1, <<", "/utf8>>) ), gleam@string:replace(_pipe@2, <<"{return}"/utf8>>, Return@1); {named, Name, _, _, []} -> Name; {named, Name@1, _, _, Params@2} -> Message@2 = <<"{name}({params})"/utf8>>, Params@3 = gleam@list:map(Params@2, fun pretty_type/1), _pipe@3 = Message@2, _pipe@4 = gleam@string:replace(_pipe@3, <<"{name}"/utf8>>, Name@1), gleam@string:replace( _pipe@4, <<"{params}"/utf8>>, gleam@string:join(Params@3, <<", "/utf8>>) ); {variable, Id} -> pretty_var(Id) end.