@@ -91,36 +91,31 @@ function catch_backtrace()
91
91
return _reformat_bt (bt[], bt2[])
92
92
end
93
93
94
- struct ExceptionStack <: AbstractArray{Any,1}
95
- stack
96
- end
97
-
98
94
"""
99
95
current_exceptions(task=current_task(); [inclue_bt=true])
100
96
101
97
Get the stack of exceptions currently being handled. For nested catch blocks
102
98
there may be more than one current exception in which case the most recently
103
99
thrown exception is last in the stack. The stack is returned as an
104
- `ExceptionStack` which is an AbstractVector of named tuples
105
- `(exception,backtrace)`. If `backtrace` is false, the backtrace in each pair
106
- will be set to `nothing`.
100
+ `ExceptionStack` which is a Vector of named tuples `(exception,backtrace)`. If
101
+ `backtrace` is false, the backtrace in each pair will be set to `nothing`.
107
102
108
103
Explicitly passing `task` will return the current exception stack on an
109
104
arbitrary task. This is useful for inspecting tasks which have failed due to
110
105
uncaught exceptions.
111
106
"""
112
107
function current_exceptions (task= current_task (); backtrace= true )
113
108
raw = ccall (:jl_get_excstack , Any, (Any,Cint,Cint), task, backtrace, typemax (Cint))
114
- formatted = Any[]
115
109
stride = backtrace ? 3 : 1
116
- for i = reverse (1 : stride: length (raw))
117
- exc = raw[i]
118
- bt = backtrace ? Base. _reformat_bt (raw[i+ 1 ],raw[i+ 2 ]) : nothing
119
- push! (formatted, (exception= exc,backtrace= bt))
120
- end
121
- ExceptionStack (formatted)
110
+ [
111
+ (exception= raw[i],
112
+ backtrace= backtrace ? Base. _reformat_bt (raw[i+ 1 ],raw[i+ 2 ]) : nothing )
113
+ for i = reverse (1 : stride: length (raw))
114
+ ]
122
115
end
123
116
117
+ const ExceptionStack = Array{NamedTuple{(:exception , :backtrace ),T}, 1 } where {T<: Tuple }
118
+
124
119
# # keyword arg lowering generates calls to this ##
125
120
function kwerr (kw, args:: Vararg{Any,N} ) where {N}
126
121
@_noinline_meta
0 commit comments