[erlang-questions] string:substr/2 gives confusing error message
Fri Dec 5 12:12:27 CET 2008
I think it is worthless work add exception raise as last clause on each
function when this error occurred in same function. Different thing is when
bad argument raise exception in some subtle internal function and worse when
it is other type than function_clause. function_clause means there is not
any clause which match to your parameters and is synonymous to badarg for
me. Adding exception raise in this case is typical defensive programming and
it is not good practice in Erlang except pattern match with tagging.
On Fri, Dec 5, 2008 at 11:12 AM, Vlad Dumitrescu <vladdu55@REDACTED> wrote:
> Calling string:substr/2 with erroneous arguments gives a
> non-informative error message
> (w@REDACTED)1> string:substr(, 2).
> ** exception error: no function clause matching string:substr2(,2)
> Shouldn't it be badarg instead, or something similar?
> Also, the strings module documentation doesn't mention what are the
> cases when the function will fail. (A quick glance shows that there
> are other functions in the same situation).
> best regards,
> erlang-questions mailing list
--Hynek (Pichi) Vychodil
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions