Exception extends Object and is the built-in structured error carrier for try / catch. Plugin typed exceptions (e.g. MySQLException) also extend Exception, so catch (Exception e) works as a generic catch-all.
| Field | Type | Description |
|---|---|---|
message |
String | Human-readable error description |
type |
String | Exception type name |
code |
Number | Numeric code (0 if unused) |
Inherits all Object methods plus one Exception-specific method:
| Method | Returns | Description |
|---|---|---|
.init(String type, String message) |
— | Set type and message fields at once |
.toString() |
String | "[type] message" |
.getType() |
String | Always "Exception" |
.isInstanceOf(String t) |
Boolean | true for "Exception" or "Object" |
try {
throw "something went wrong";
} catch (Exception e) {
Konsol:Print(e.message); // something went wrong
Konsol:Print(e.type); // Exception
Konsol:Print(e.code); // 0
}
Throw any string value and the engine wraps it in an Exception automatically. Use e.message to read the string back.
Plugins throw named subtypes (e.g. MathException, ArrayException, MySQLException). Catch the specific type first, then use Exception as a fallback — the engine picks the first matching catch block:
try {
MySQL:Connect("localhost", "root", "wrongpass", "mydb", db);
} catch (MySQLException e) {
Konsol:Print("MySQL error ${e.code}: ${e.message}");
} catch (Exception e) {
Konsol:Print("Unexpected: ${e.message}");
}
More specific types must be named exactly; catch (Exception e) will not fire if an earlier catch already matched.
Class:Exception err;
err.init("ValidationError", "email field is required");
throw err;
getType, toString, isInstanceOftry / catch / finally, throw, typed built-in exceptions