-module(priv@errors). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([map_messages/3, map_error/2, print_result/1, print_error/1, assert_ok/1]). -file("/Users/john.bjork/git/adglent/src/priv/errors.gleam", 5). -spec map_messages({ok, any()} | {error, any()}, binary(), binary()) -> {ok, binary()} | {error, binary()}. map_messages(Result, Success_message, Error_message) -> _pipe = Result, _pipe@1 = gleam@result:map_error( _pipe, fun(Error) -> <<<<<<"Error - "/utf8, Error_message/binary>>/binary, ": "/utf8>>/binary, (gleam@string:inspect(Error))/binary>> end ), gleam@result:replace(_pipe@1, Success_message). -file("/Users/john.bjork/git/adglent/src/priv/errors.gleam", 17). -spec map_error({ok, OTK} | {error, any()}, binary()) -> {ok, OTK} | {error, binary()}. map_error(Result, Error_message) -> _pipe = Result, gleam@result:map_error( _pipe, fun(Error) -> <<<>/binary, (gleam@string:inspect(Error))/binary>> end ). -file("/Users/john.bjork/git/adglent/src/priv/errors.gleam", 27). -spec print_result({ok, binary()} | {error, binary()}) -> {ok, binary()} | {error, binary()}. print_result(Result) -> _pipe = Result, _pipe@1 = gleam@result:unwrap_both(_pipe), gleam@io:println(_pipe@1), Result. -file("/Users/john.bjork/git/adglent/src/priv/errors.gleam", 34). -spec print_error({ok, OTT} | {error, binary()}) -> {ok, OTT} | {error, binary()}. print_error(Result) -> _pipe = Result, gleam@result:map_error( _pipe, fun(Err) -> gleam@io:println(Err), Err end ). -file("/Users/john.bjork/git/adglent/src/priv/errors.gleam", 42). -spec assert_ok({ok, OTX} | {error, binary()}) -> OTX. assert_ok(Result) -> _assert_subject = begin _pipe = Result, gleam@result:map_error( _pipe, fun(Err) -> erlang:halt(1), Err end ) end, {ok, Value} = 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 => <<"priv/errors"/utf8>>, function => <<"assert_ok"/utf8>>, line => 43}) end, Value.