Of course, just add the fields to your exception type:
Nim
type
MyException = ref object of Exception
extraData: string
proc raiseSomething() =
var e: MyException
new(e)
e.extraData = "Hello world"
e.msg = "This is the normal message"
raise e
try:
raiseSomething()
except MyException as e:
echo e.msg
echo e.extraData
Run
- Can I throw errors with custom fields? jiyinyiyong
- Re: Can I throw errors with custom fields? PMunch
