Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EEP 54: Extended error information for BIFs #14

Merged
merged 1 commit into from
Nov 3, 2020

Conversation

bjorng
Copy link
Contributor

@bjorng bjorng commented Oct 20, 2020

No description provided.

eeps/eep-0054.md Outdated Show resolved Hide resolved
eeps/eep-0054.md Outdated Show resolved Hide resolved
@bjorng
Copy link
Contributor Author

bjorng commented Oct 21, 2020

I have changed the return value of format_error/3 to be a map. That way, in the future it would be easier to provide more information about errors in a backwards-compatible way. (Suggested by José Valim.)

eeps/eep-0054.md Outdated Show resolved Hide resolved
eeps/eep-0054.md Outdated Show resolved Hide resolved
@bjorng
Copy link
Contributor Author

bjorng commented Oct 28, 2020

I have now updated the reference implementation to provide extended error information for most C-implemented BIFs in the erlang module. (It remains to provide extended error information for Erlang-implemented BIFs in the erlang module.)

I found one BIF that will raise a badarg exception even if the arguments are good, namely monitor_node/2:

1> monitor_node(node@host, true).
** exception error: bad argument
     in function  monitor_node/2
        called as monitor_node(node@host,true)

If distribution is not started (the current node is not alive), monitor_node/2 always raises a badarg exception. With the suggested way of always associating a message to a specific argument, there is no way to provide extended error information.

Should we change monitor_node/2 to raise another exception if the current node is not alive, for example not_alive?

Or should we extend the EEP to allow the reporting of a message not associated with any of the arguments?

Or maybe allow format_error/3 to change the badarg to something else? That is, make it possible to produce the following message:

1> monitor_node(node@host, true).
** exception error: the current node is not alive
     in function  monitor_node/2
        called as monitor_node(node@host,true)

@bjorng bjorng merged commit 2d59d5e into erlang:master Nov 3, 2020
@bjorng bjorng deleted the bjorn/eep-0054 branch November 3, 2020 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants