Skip to content

Martini Services Block Step

Overview

Block steps are used to group multiple steps together in a structured manner, akin to using braces ({}) in Java and similar languages. They are crucial for organizing code, handling exceptions, and controlling variable scope.

Scoping and Grouping

Variables declared within a block step are confined to that block and its child elements, mirroring the scope behavior in Java. This encapsulation aids in maintaining clean and manageable code.

Block Type Property

The functionality of a block step can be altered by adjusting the 'Block Type' property. To change this, select the block step and modify its type via the Properties view.

Exception Handling

Exception handling within the platform follows a structured approach:

  1. Propagation: If a service encounters an exception, the platform traces up the stack to locate a corresponding catch block. If none are found, the exception exits the platform and is handled by Martini.

  2. Catch Block Variables: In a catch block, a special variable ($exceptionVariable) becomes available, encapsulating the thrown exception. This is where exception handling should be implemented.

Adding Block Steps

Block steps can be added through various methods:

  • Standard Addition: Utilize the add button, hotkeys, or the content-assist menu.
  • Pre-configured Options: The platform offers pre-set block step configurations (like try-catch, try-finally) in the content-assist menu for convenience.

Quick Fixes for Exceptions

The platform identifies unhandled exceptions within steps. To address these, right-click on the warning or error icon to access a set of corrective options, simplifying the error resolution process.