Error Handling

  Lisp language configured for easy creation of programs from data. To verify that created the program worked, sometimes the only solution is to run the program. When an error occurs in the program up a system check (the exception). If after calculating the problem check exception raised, then you can run other tasks for the error restoration.
  Function try runs the task. When an exception is checked the error code. Check with the command eq, that is, identity.

(nil  try (nil  eval  task)
  out-of-memory (cout writeln "Out of memory")
  nil (cout writeln "Task " task  " is wrong"))

  The error may be a symbol, a list or other specified by command throw. The latest error code can be nil, to intercept all exceptions. To find out what went wrong, you can use the function exception.

(nil  try (nil  eval  task)
  nil (cout writeln "Exception is " (nil  exception)))

  As an example of using could serve the function of add numbers to the vector. If you receive an error function does not know what to do and sends a signal to function that caused it.

('vector  defmethod add-number  (x  n)
  (nil  if  (nil  numberp x)
    (nil  if  (nil  numberp n)
      (nil  try (this push  x n)
        nil (nil  throw 'out-of-memory))
      (nil  throw 'syntax))
    (nil  throw 'syntax)))
(nil  setq  v ('vector  newobject))
(nil  try (v  add-number  "1")
  nil (cout writeln "error: " (nil  exception)))
(nil  try (v  add-number  1 1e10)
  nil (cout writeln "error: " (nil  exception)))

  The result will be error output syntax and out-of-memory.

  The most important aspect of debugging programs is to derive the history of computing at the time when an exception is identified. History can be obtained by using (nil exception-history). History is defined as a list (… command …).