🤩

Erlang のエラー情報の拡張

2020/12/15に公開

まとめ

一目瞭然です。

いままで

Erlang/OTP 23 [erts-11.1.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]

Eshell V11.1.3  (abort with ^G)
1> erlang:element(a, b).
** exception error: bad argument
     in function  element/2
        called as element(a,b)

今後

Erlang/OTP 24 [DEVELOPMENT] [erts-11.1.3] [source-54ce4aefca] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Eshell V11.1.3  (abort with ^G)
1> erlang:element(a, b).
** exception error: bad argument
     in function  element/2
        called as element(a,b)
        *** argument 1: not an integer
        *** argument 2: not a tuple

概要

EEP 54: Provide more information about errors

今までの Erlang/OTP で BIF が上げる例外は残念極まりなかったのですが、それがわかりやすくなります。

PR

Add extended error information for all BIFs in the ERTS application by bjorng · Pull Request #2925 · erlang/otp

内容

> list_to_binary(a).
** exception error: bad argument
     in function  list_to_binary/1
        called as list_to_binary(a)
        *** argument 1: not an iolist term

> integer_to_binary(a).
** exception error: bad argument
     in function  integer_to_binary/1
        called as integer_to_binary(a)
        *** argument 1: not an integer

雑感

最高です。

Discussion