kinx

Looks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers.

This project is maintained by Kray-G

defineException function

Overview

You can define your own exception by System.defineException() as below.

YourOwnExceptionClass = System.defineException('YourOwnException');
YourOwnException = YourOwnExceptionClass.create;

If you want to make your own library, it will be useful for your error notification.

Examples

Example 1. Normal case

Code

YourOwnExceptionClass = System.defineException('YourOwnException');
YourOwnException = YourOwnExceptionClass.create;

class TheClass {
    private initialize() {
        throw YourOwnException("Error!");
    }
}

function test() {
    var x = new TheClass();
    return x;
}

test();

Result

Uncaught exception: No one catch the exception.
YourOwnException: Error!
Stack Trace Information:
        at function TheClass#initialize(test.kx:6)
        at function TheClass(test.kx:4)
        at function test(test.kx:11)
        at <main-block>(test.kx:15)