Skip to content

Commit

Permalink
refactor: use show_exception_stack instead of showerror to show neste…
Browse files Browse the repository at this point in the history
…d exceptions
  • Loading branch information
mchitre committed Feb 8, 2024
1 parent 2195beb commit 3603af5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/container.jl
Original file line number Diff line number Diff line change
Expand Up @@ -710,21 +710,21 @@ Run function `f()` and log any errors that occur.
function logerror(f::Function, src=nothing)
try
f()
catch ex
logerror(ex, src)
catch
logerror(src)
end
end

"""
logerror(err::Exception)
logerror(err::Exception, src)
logerror()
logerror(src)
Log error `err` with a simple stack trace.
Log current exception with a stack trace.
"""
function logerror(ex::Exception, src=nothing)
function logerror(src=nothing)
io = IOBuffer()
src === nothing || print(io, "[$src] ")
Base.showerror(IOContext(io, :limit => true), ex, Base.catch_backtrace())
Base.show_exception_stack(IOContext(io, :limit => true), Base.catch_stack())
@error String(take!(io))
end

Expand Down

0 comments on commit 3603af5

Please sign in to comment.