I am error.
The first errors you are likely to run into are syntax errors. These include simple bugs where your code doesn't following Zaidlang grammar, like:
1 + * 2
Zaidlang detects these errors as soon as it tries to read your code. When it hits one, you get a friendly error message, like:
[line 1] Error at '*': Expect expression.l
Some slightly more "semantic" errors fall into this bucket too, like using a variable that hasn't been defined:
Zaidlang tells you:
1:7:repl.zaid: runtime error: unknown identifier: message
Note that it does this before it executes any code. Unlike some other scripting languages, Zaidlang tries to help you find your errors as soon as possible when it can.
If it starts running your code, you can be sure you don't have any errors related to syntax or variable scope.
There is one more round of errors that Zaidlang will emit. Your program may still have errors that can't be detected statically. Since they can't be found until your code is run, they're called "runtime" errors.
Most runtime errors come from the evaluation of your code itself. They arise from code trying to perform an operation that Zaid can't do. The most common error is a "method not found" one. If you call a method on an object and its class doesn't define that method, there's nothing Zaidlang can do:
foo = Foo.new()
If you run this, Zaidlang will print:
1:4:repl.zaid: runtime error: undefined method someRandomMethod for class Foo
Then it stops executing code. Unlike some other languages, Zaidlang will not keep plugging away after a runtime error has occured.
This is just one example of a runtime error, but there are others. A runtime error implies there's a bug in your code and it wants to draw your attention to it.
Most runtime errors come from within the Zaidlang evaluator, but you may want to be able to cause your own runtime errors to occur. This can be done by calling the
zaid.abort("Something bad happened")
You must pass in an error message, and it must be a string. If the provided message is
null, no runtime error is raised.