Skip to content

Better errors than badarg #58

@eproxus

Description

@eproxus

Is there any plan to add better errors than just badarg? It's problematic when trying to encode/decode inside more complex code:

    try
        complex_code(Binary) % Code that calls jsone:decode somewhere
    catch
        error:badarg:ST ->
            case ST of
                [{jsone_decode,_,_,_}|_] ->
                        ?LOG_WARNING("Bad JSON: ~p", [Binary]);
                _ ->
                    erlang:raise(error, badarg, ST)
            end
    end.

It's impossible to know where the badarg error comes from without checking the stack trace.

I apologize if this have been considered already, since there might be a lot of code changes / possible overhead (e.g. if try-catch is used).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions