Skip to content

Commit

Permalink
make error work before Base
Browse files Browse the repository at this point in the history
  • Loading branch information
samoconnor committed Apr 18, 2016
1 parent 85c1193 commit 238167f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions base/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type AssertionError <: Exception
AssertionError() = new("")
AssertionError(msg) = new(msg)
end
isfatal(::AssertionError) = true

#Generic wrapping of arbitrary exceptions
#Subtypes should put the exception in an 'error' field
Expand Down
21 changes: 13 additions & 8 deletions base/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@

## native julia error handling ##

error(s::AbstractString) = throw(Main.Base.ErrorException(s))
error(s...) = throw(Main.Base.ErrorException(Main.Base.string(s...)))
if isdefined(Main, :Base)
error(s::AbstractString) = throw(ErrorException(s))
error(s...) = error(string(s...))
else
type CoreErrorException <: Exception
msg
end
error(s...) = throw(CoreErrorException(s))
end

rethrow() = ccall(:jl_rethrow, Bottom, ())
rethrow(e) = ccall(:jl_rethrow_other, Bottom, (Any,), e)
Expand Down Expand Up @@ -52,18 +59,16 @@ end

## fatal errors ##

isfatal(error) = false
isfatal(::StackOverflowError) = true
isfatal(::Exception) = false
isfatal(::OutOfMemoryError) = true
isfatal(::StackOverflowError) = true
isfatal(::SegmentationFault) = true
isfatal(::UndefRefError) = true
isfatal(::UndefVarError) = true

enable_catch_fatal() = ccall(:jl_enable_catch_fatal, Void, ())
disable_catch_fatal() = ccall(:jl_disable_catch_fatal, Void, ())
if isdefined(Main, :Base)
rethrow_if_fatal(error) = isfatal(error) && ccall(:jl_rethrow_fatal, Void, ())
else
rethrow_if_fatal(error) = nothing
end


"""
Expand Down

0 comments on commit 238167f

Please sign in to comment.