I’m working on a Julia project where I have defined a custom exception type like this:
struct XXXError <: Exception
e::String
end
Now, I want to customize how instances of this exception type are displayed. I understand that I can achieve this by extending either the Base.show
or Base.showerror
function. However, I’m not entirely sure about the differences between these two functions and in which situations I should use each.
From what I understand, Base.show
is a general function used to display objects in Julia, while Base.showerror
is specifically used to display error messages. Is my understanding correct? I see most Exception
types just define Base.showerror
.
Could someone please explain the key differences between extending Base.show
and Base.showerror
for a custom exception type? And could you also provide guidance on when to use each? Thank you.