@vlandau wrote:
Is there an equivalent in Julia to the
stop()
function in R? The nice thing aboutstop()
is that it can be run from any scope (e.g. a function within a function) and it will throw an error and terminate the function that the user called.I see that
throw()
in Julia does something similar, but I’d like to avoid printing a stack trace because it is not necessary for the info I’m trying to convey to users (e.g. two arrays provided as arguments are not the same size, but they need to be)For now, I’m doing things like:
there_is_an_error = check_for_the_error(arg1, arg2) # returns a Bool there_is_an_error && (@error "error message"; return)
I’d like to be able to have everything contained inside of
check_for_the_error()
to make the code more tidy.Also open to suggestions for different approaches entirely.
Thanks!
Posts: 10
Participants: 5