Is it possible to get the type of exception as a string when doing a generic exception catch?
try:
someCode()
except Exception:
var exc = getCurrentException()
# Somehow echo exc's actual type? ie: OSError, etc.
For einheit, I'd like to print out what exception was actually thrown by a piece of code for a checkRaises() template.
The typeinfo module didn't seem to do the trick, but maybe I'm using it wrong. I used e.toAny().kind. Is that the correct way of using it? The result of those calls is the kind akRef.
What did you mean by a Toronto parameter? I'm not familiar with the term :)
Isn't it possible to get an objects runtime type as a typedesc?
The code the OP was trying to get to would be something similar to:
import typetrait
...
name(type(exc))
But that only returns "ref Exception".
@Araq, you were right :) I had another stdlib installation messing with me. It works now and I've created a pull request.
@OderWat, that looks awesome! I will definitely give it a try :)