Skip to content

Commit

Permalink
make rethrow_if_fatal work in Core
Browse files Browse the repository at this point in the history
  • Loading branch information
samoconnor committed Apr 18, 2016
1 parent 97f21fd commit 51bdd4a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions base/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}, ())
Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit 51bdd4a

Please sign in to comment.