JuliaLang/julia — pull request #4249 by ivarne (2013-09-10 20:10:08+00:00)
Title: Added helpfull message for DomainError

Some functions throw DomainError for Real arguments because of type
stability and that the correct answer is complex. This patch add a ugly
hack, inspecting the bactrace, to give newcommers a helpefull hint.

julia> sqrt(-1)
ERROR: DomainError
sqrt will only return complex result if called width a complex argument. Eg: sqrt(complex(x))

julia> log(-1)
ERROR: DomainError
log will only return complex result if called width a complex argument. Eg: log(complex(x))

See: https://github.com/JuliaLang/julia/issues/2144

I hate that this approach includes a list of functions (:log, :log2, :log10, :sqrt) that has to be updated and can not be extended by module writers, but from the discussion in #2144 it looks like something that might be accepted.