[erlang-questions] Improve errors for maps

Björn-Egil Dahlberg wallentin.dahlberg@REDACTED
Fri Feb 27 18:26:33 CET 2015


2015-02-27 15:17 GMT+01:00 José Valim <jose.valim@REDACTED>:

> Since maps are still marked are experimental, I would love if we take the
> opportunity to improve the errors coming from map operations.
>
> For example, a bad update just fails with badarg, without giving further
> hints of what went wrong:
>
> 1> (foo)#{foo := 1}.
> ** exception error: bad argument: foo
>
> Or when the key does not exist:
>
> 1> (#{})#{foo := 1}.
> ** exception error: bad argument
>      in function  maps:update/3
>
> Although the shell helps a bit with formatting it, it is hard to decipher
> in logs and we frequently have reports of the error message not being clear
> to developers.
>
> I would love if we could, at least for the syntax based operations,
> introduce two errors:
>
> 1. {badmap, Term} - raised when a map was expected but got something else
> (this would replace the first error and it is an improvement over the error
> records used to raise)
>
> 2. {badkey, Key, Map} - raised when we expected a Map to have Key but it
> does not. Useful for the := syntax and it could also be used if we ever add
> an access operation to maps
>
> If we segregate the errors as proposed, we will have plenty of opportunity
> to improve the reports in shell and in error loggers.
>
> Thoughts?
>


My relocation is that we already decided on this format? Pretty much
precisely as you described it. It could just be long term deja vu on my
part though.

Is it your way of saying, "do it already" ? =D

But yeah, +1

// Björn-Egil


>
> *José Valim*
> www.plataformatec.com.br
> Skype: jv.ptec
> Founder and Lead Developer
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150227/367cb0c0/attachment.htm>


More information about the erlang-questions mailing list