A Julia equivalent to R's stop()?

struct NoBackTraceException
    exc::Exception
end

function Base.showerror(io::IO, ex::NoBackTraceException, bt; backtrace=true)
    Base.with_output_color(get(io, :color, false) ? Base.error_color() : :nothing, io) do io
        showerror(io, ex.exc)
    end
    # look ma, no backtrace
end

f() = g()
g() = h()
h() = throw(NoBackTraceException(ErrorException("foo")))
julia> f()
ERROR: foo

julia>

Not really a good idea :man_shrugging:

5 Likes