Skip to content

Typecasting errors can't be customized #44

@seancribbs

Description

@seancribbs

clique_error defines how to format all errors, but if I want to validate a flag is properly formed, I can't customize the output (actually I'll probably get function_clause). Example typecasting function:

ip(String) ->
    try
        [Ip, PortStr] = string:tokens(String, ":"),
        {ok, _} = inet_parse:address(Ip),
        Port = list_to_integer(PortStr),
        {Ip, Port}
    catch
        error:badarg ->
            {error, port_is_not_integer};
        error:badmatch ->
            {error, invalid_address}
    end.

I should be able to use symbolic errors in this case or handle them explicitly by running the command with flagged inputs. Currently I can do neither because clique_error is called immediately upon encountering an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions