Closed nickrobinson251 closed 4 years ago
I think the typical pattern for this is to wrap the exception in another exception
I am glad there is another way, but I do not know what that means, please can you give an example?
try
...
catch err
err isa ArgumentError || rethrow(err)
error(logger, ErrorException("message ... " * sprint(io -> showerror(io, err)))
end
If it is a common enough pattern then typically a new container exception type is defined (e.g.,HTTP.IOError
, CaptureException
). NOTE: There has been some discussion that error
shouldn't actually throw an error, but rather just log it and requiring a separate throw
.
Unless I'm mistaken there isn't anything here that Memento needs to fix?
error(logger::Logger, msg::AbstractString, e::Excpetion) = error(logger, ErrorException(msg * sprint(io -> showerror(io, e)))
?
Currently I write something like this (or some other workaround)
But perhaps it should be possible to write this?