As I was implementing an
Exception subtype for the first time, I looked at some implementations in Base, for example
ArgumentError. I was surprised by two things:
- a lot of the subtypes are
- a lot of the subtypes don’t have concretely typed fields
On the other hand, the documentation refers to
UndefVarError as an example of how to write a custom exception type, which is an immutable
struct without abstract fields.
Just wondering: why is this? Also: does this have anything to do with the practice of throwing in a separate,
@noinline'd function to achieve maximal performance? Ref e.g.: https://github.com/JuliaLang/julia/pull/23088#issuecomment-320279238.