From 51bdd4a327b65a880f2db0332f9e1c69caaf8f55 Mon Sep 17 00:00:00 2001 From: Sam O'Connor Date: Mon, 18 Apr 2016 10:01:53 +1000 Subject: [PATCH] make rethrow_if_fatal work in Core --- base/error.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/base/error.jl b/base/error.jl index 26046f12346b8..d26a4c4463d39 100644 --- a/base/error.jl +++ b/base/error.jl @@ -21,7 +21,11 @@ error(s::AbstractString) = throw(Main.Base.ErrorException(s)) error(s...) = throw(Main.Base.ErrorException(Main.Base.string(s...))) -rethrow() = ccall(:jl_rethrow, Bottom, ()) +if isdefined(Main, :Base) + rethrow() = ccall(:jl_rethrow, Bottom, ()) +else + rethrow() = ccall(:jl_rethrow, Core.Bottom, ()) +end rethrow(e) = ccall(:jl_rethrow_other, Bottom, (Any,), e) backtrace() = ccall(:jl_backtrace_from_here, Array{Ptr{Void},1}, (Int32,), false) catch_backtrace() = ccall(:jl_get_backtrace, Array{Ptr{Void},1}, ()) @@ -53,15 +57,13 @@ end ## fatal errors ## isfatal(error) = false -if isdefined(Main, :Base) isfatal(::StackOverflowError) = true isfatal(::OutOfMemoryError) = true isfatal(::UndefVarError) = true -end enable_catch_fatal() = ccall(:jl_enable_catch_fatal, Void, ()) disable_catch_fatal() = ccall(:jl_disable_catch_fatal, Void, ()) -rethrow_if_fatal(error) = ccall(:jl_catch_fatal_is_enabled, Cint, ()) != 0 || +rethrow_if_fatal(error) = ccall(:jl_catch_fatal_is_enabled, Cint, ()) == 0 && isfatal(error) && rethrow(error)