Introduction:

In programming, errors can occur due to a variety of reasons such as syntax errors, semantic errors, and runtime errors. It is important to handle these errors effectively to ensure that programs run smoothly and avoid unexpected crashes. In this documentation, we will explore how errors are handled in Artsy programming language.

Error Types:

Syntax Error:

These errors occur when the code violates the rules of the language's syntax. For example, a missing semicolon, or an unmatched parenthesis. When a syntax error occurs, the program will not compile or execute.

Example:

declare x as int;
let x = 0
print x;

Returns

Syntax error, line 3

Semantic Error:

These errors occur when the code violates the rules of the language's semantics. For example, declaring a variable as a string and then trying to store an integer in it. These types of errors will cause the program to execute, but the output may not be as expected.

Example:

declare myString as string;
let myString = 0;
print x;

Returns

Semantic Error, line 3: The type of "myString" does not match the type of "int".

Runtime Error:

These errors occur during program execution. They may be caused by a variety of factors, such as division by zero, or trying to access an undeclared variable. These errors can cause the program to crash.

Examples: