Skip to content

Commit

Permalink
Unexport catch_stack
Browse files Browse the repository at this point in the history
This API is experimental in julia 1.1 and will be replaced with
something more convenient (see #29901). In the meantime, make sure it's
clearly marked as experimental and not exported from Base.
  • Loading branch information
c42f committed Dec 9, 2018
1 parent c2fb1dc commit 1bd316b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Julia v1.1 Release Notes
New language features
---------------------

* An *exception stack* is maintained on each task to make exception handling more robust and enable root cause analysis using `catch_stack` ([#28878]).
* An *exception stack* is maintained on each task to make exception handling
more robust and enable root cause analysis. The stack may be accessed using
the experimental function `Base.catch_stack` ([#28878]).
* The experimental macro `Base.@locals` returns a dictionary of current local variable names
and values ([#29733]).

Expand Down
3 changes: 2 additions & 1 deletion base/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ arbitrary task. This is useful for inspecting tasks which have failed due to
uncaught exceptions.
!!! compat "Julia 1.1"
This function requires at least Julia 1.1.
This function is experimental in Julia 1.1 and will likely be renamed in a
future release (see https://github.com/JuliaLang/julia/pull/29901).
"""
function catch_stack(task=current_task(); include_bt=true)
raw = ccall(:jl_get_excstack, Any, (Any,Cint,Cint), task, include_bt, typemax(Cint))
Expand Down
1 change: 0 additions & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,6 @@ export
# errors
backtrace,
catch_backtrace,
catch_stack,
error,
rethrow,
retry,
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ The power of the `try/catch` construct lies in the ability to unwind a deeply ne
immediately to a much higher level in the stack of calling functions. There are situations where
no error has occurred, but the ability to unwind the stack and pass a value to a higher level
is desirable. Julia provides the [`rethrow`](@ref), [`backtrace`](@ref), [`catch_backtrace`](@ref)
and [`catch_stack`](@ref) functions for more advanced error handling.
and [`Base.catch_stack`](@ref) functions for more advanced error handling.

### `finally` Clauses

Expand Down
6 changes: 3 additions & 3 deletions doc/src/manual/stacktraces.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ ERROR: Whoops!
[...]
```

## Exception stacks and [`catch_stack`](@ref)
## Exception stacks and `catch_stack`

!!! compat "Julia 1.1"
Exception stacks requires at least Julia 1.1.
Expand All @@ -197,7 +197,7 @@ identify the root cause of a problem. The julia runtime supports this by pushing
*exception stack* as it occurs. When the code exits a `catch` normally, any exceptions which were pushed onto the stack
in the associated `try` are considered to be successfully handled and are removed from the stack.

The stack of current exceptions can be accessed using the [`catch_stack`](@ref) function. For example,
The stack of current exceptions can be accessed using the experimental [`Base.catch_stack`](@ref) function. For example,

```julia-repl
julia> try
Expand All @@ -206,7 +206,7 @@ julia> try
try
error("(B) An exception while handling the exception")
catch
for (exc, bt) in catch_stack()
for (exc, bt) in Base.catch_stack()
showerror(stdout, exc, bt)
println()
end
Expand Down
1 change: 1 addition & 0 deletions test/exceptions.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Test
using Base: catch_stack

@testset "Basic exception stack handling" begin
# Exiting the catch block normally pops the exception
Expand Down

0 comments on commit 1bd316b

Please sign in to comment.