[erlang-questions] string:substr/2 gives confusing error message

Vlad Dumitrescu <>
Fri Dec 5 12:17:45 CET 2008

On Fri, Dec 5, 2008 at 12:12, Hynek Vychodil <> wrote:
> I think it is worthless work add exception raise as last clause on each
> function when this error occurred in same function.

>> ()1> string:substr([], 2).
>> ** exception error: no function clause matching string:substr2([],2)

Except it's not the same function: notice the error refers to string2,
not to string.

Yes, it's relatively easy to check the code and see what's going
wrong, but then any documentation is redundant, as one could check the

In any case, badarg is the standard exception thrown in similar cases,
so why not be consistent?


More information about the erlang-questions mailing list