Class: Toybox::Lang::Exception

Inherits:
Object
  • Object
show all

Overview

Exception is a class that represents a thrown Exception. Custom exceptions can be created by extending this class.

Examples:

Creating and throwing a new Exception class

using Toybox.Lang;
var myVar;

class myException extends Lang.Exception {
    function initialize() {
        Exception.initialize();
    }
}

if (myVar == false) {
    throw new myException();
}

Handling an Exception in a try-catch block

using Toybox.Lang;
using Toybox.System;
try {
    // Do something here
} catch (e instanceof Lang.Exception) {
    System.println(e.getErrorMessage());
}

Since:

  • 1.0.0

Instance Method Summary collapse

Methods inherited from Object

equals, hashCode, method, toString, weak

Constructor Details

initializeException

Exception constructor.

Since:

  • 1.1.2


7465
7466
# File 'Monkeybrains.rb', line 7465

def initialize()
end

Instance Method Details

getErrorMessageToybox::Lang::String

Get the error message for the Exception.

Returns:

Since:

  • 1.2.0


7477
7478
# File 'Monkeybrains.rb', line 7477

def getErrorMessage()
end

printStackTraceObject

Print the stack trace of the thrown Exception.

Since:

  • 1.1.2


7470
7471
# File 'Monkeybrains.rb', line 7470

def printStackTrace()
end