Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexport catch_stack #30316

Merged
merged 1 commit into from
Dec 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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