Julia idiomatic way of catching exceptions except of interrupt?

Viewed 137

Quite often I process data in Julia and don't want it to crash it, so I use try-catch block. But I'm also debugging it in REPL and then I actually want to kill the block if I see it's doing something wrong. So far my solution is

for i in <some big loop>
    try
        do_job(i)
    catch e
        e isa InterruptException && rethrow(e)
        @warn "job failed" i e
    end
end

but it does not feel very idiomatic. Is there something better? I saw this 7 years old question https://github.com/JuliaLang/julia/issues/4037 but it still seems unsolved.

0 Answers
Related