Class monkey.lang.Throwable - leonard-thieu/monkey GitHub Wiki

The Throwable class must be extended by all classes that are intended to be used with Throw.

Extended by

Detailed Discussion

The Throwable class must be extended by all classes that are intended to be used with Throw.

The Throwable class currently has no members.

Any attempt to throw an object that doesn't extend Throwable will result in a compile time error.

Class MyThrowable Extends Throwable

    Field msg:String

    Method New( msg:String )
        Self.msg=msg
    End
End

Function Test:Void()
    Throw New MyThrowable( "Thrown!" )
End

Function Main()
    Try
        Test
    Catch t:MyThrowable
        Print "MyThrowable thrown: msg="+t.msg
    End
End
⚠️ **GitHub.com Fallback** ⚠️