Typed runtime errors implement SPLException
with a .kind string. You can catch
them with structured try/except in SPL.
error.DivisionByZeroError — e.g. math.div by zeroerror.IndexOutOfRangeError — list, string, tuple boundserror.UndefinedVariableError — unknown identifiererror.FileNotFoundError / error.IOError — file I/O
Handlers are merged when error.try():
is immediately followed by one or more
error.except(...): blocks. String
literals can match .kind as well.
Uncaught errors print an SPL call stack (most recent call last) when the
failure happened inside a user function, instance method, or
used module. Example shape:
Error: [Line 12] DivisionByZeroError: division by zero SPL stack (most recent call last): line 4: module /path/to/helper.spl line 12: function boom
Raise your own typed errors with
error.raise(error.SomeKind, "message")
(after errorDefine if custom).