Closed DilumAluthge closed 4 years ago
What does it matter?
All exceptions in Base are subtypes of Exception
, and the manual recommends doing the same for custom errors:
You may define your own exceptions in the following way:
julia> struct MyCustomException <: Exception end
In one of my use cases, I catch all exceptions during execution of a program and log them at the end. I store them in a Vector{Exception}
, which seems appropriate given the quote from the manual. Unfortunately this fails if I try to push a MissingExternalProgramError
into that Vector
.
I think it's reasonable for a caller to expect that anything that is thrown is a subtype of Exception
.
In my use case, I fixed the problem by switching to using a Vector{Any}
to store the exceptions. But in general I think it's good practice for things that are throw
n to be subtypes of Exception
.
MissingExternalProgramError
is defined here as:Is there any particular reason why
MissingExternalProgramError
is not a subtype ofException
?