Exception handling

Table of contents

  1. Raising and catching

Raising and catching

In the following an exception of type E is thrown an then catched.

E = table{}

try
   raise table E{value = "Some message"}
catch e if e: E
   print(e.value)
end

The catch-part is only reached if the exception is of type E. It can also be stated by means of an unconditional catch.

try
   raise table E{value = "Some message"}
catch e
   if e: E
      print(e.value)
   else
      raise e
   end
end

But in case of an unconditional catch, the traceback so far will be clipped off.