handling standard errors
Posted: Sat Dec 12, 2015 1:09 am
I have the following piece of code:
param is arbitrary. If there is any error, it ends up in debugger. I wanted to avoid this by adding an error handler:
This works great, but I have no information on the type of the error.
I wondered if there is some way to access properties of the error so I can display something to the caller like "division by zero" or "invalid number of arguments" or something like that. I did some googling but the examples I found are only for creating custom conditions and catching them - but in this case I may have a standard error.
Code: Select all
(defun func1 (param)
(eval (read-from-string param)))
Code: Select all
(defun func2 (param)
(handler-case
(eval (read-from-string param))
(error () "error")))
I wondered if there is some way to access properties of the error so I can display something to the caller like "division by zero" or "invalid number of arguments" or something like that. I did some googling but the examples I found are only for creating custom conditions and catching them - but in this case I may have a standard error.