File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -40,8 +40,8 @@ proper way is refreshing the `current_task` (the variable `t`) in
4040function task_wrapper (func)
4141 () ->
4242 try
43- res = func ()
4443 ct = current_task ()
44+ res = func ()
4545 ct. result = res
4646 isa (ct. storage, Nothing) && (ct. storage = IdDict ())
4747 ct. storage[:_libtask_state ] = :done
@@ -83,6 +83,19 @@ function Base.copy(t::Task)
8383 newt
8484end
8585
86+ struct CTaskException
87+ msg:: String
88+ backtrace:: Vector{Union{Ptr{Nothing}, Base.InterpreterIP}}
89+ end
90+
91+ function Base. show (io:: IO , exc:: CTaskException )
92+ println (io, " Stacktrace in the failed task:\n " )
93+ println (io, exc. msg * " \n " )
94+ for line in stacktrace (exc. backtrace)
95+ println (io, string (line))
96+ end
97+ end
98+
8699produce (v) = begin
87100 ct = current_task ()
88101
@@ -178,7 +191,7 @@ consume(p::Task, values...) = begin
178191 return p. result
179192 end
180193 if p. exception != nothing
181- throw (p. exception)
194+ throw (CTaskException ( p. exception. msg, p . backtrace) )
182195 end
183196 end
184197 wait ()
You can’t perform that action at this time.
0 commit comments