Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
As part of my Creo Elements/Direct customization, I am trying to do some basic exception handling in Lisp. For Common Lisp, the internet seems to recommend using the handler-case macro. When I run
(do-symbols (s (find-package "lisp"))
(display s))
in the Creo input line, handler-case is indeed listed. But when I try to run code that uses it I always get "LISP error: The function HANDLER-CASE is undefined." Am I missing something or is there some other method of doing exception handling that is preferred?
If you'd like a toy example to test with, here's a divider that instead of throwing an arith-error (e.g. on divide-by-zero), returns nil instead. Putting this into the input line defines the function fine, but calling it results in the "function undefined" error. I tried replacing handler-case with lisp::handler-case and a few others with no luck.
(defun my-safe-divider (a b)
(handler-case (/ a b)
(arith-error nil)))
Any help appreciated,
Rich Kinder
I tried typing this into the input line but I still get a "LISP Error: Zero Divisor" popup, which is what I'm trying to suppress.
(progn
(defun my-safe-divider (a b)
(unwind-protect (/ a b)))
(display (my-safe-divider 1 0)))
If I call my-safe-divider with, say, 6 and 2 instead of 1 and 0 it displays 3 as expected.