The MSPro Boomi Collection
About
Good Practices & Patterns
Good Practices & Patterns
  • Markus' Boomi Integration
  • Implementation Patterns
    • The Cache Challenge
      • The Get-Or-Create Use-Case
      • PropCache Scripts
    • State Management
      • Example Scenario
      • State-Management in general
      • State-Management Functionality
      • Technical Solutions
        • Boomi File-System Implementation
          • saveState
          • readState & fetchStates
    • Exception Handling
      • Exception vs Error
      • Basic Rules
        • Aggregating Exceptions
      • Exception Handling Pattern
        • User-Defined Exception Messages
        • Catch Exceptions
      • The pattern in practice
        • API Error Handling
          • Single Record Strategy
            • Single Record RES
          • Many Records Strategy (Array)
            • Many Records RES
        • Pre-Condition Check
    • SQL Patterns
      • Script Header
      • General Rules
        • Check using RowCount
        • Check if record exists
        • Pagination and Sorting
        • Parameter - Best Practices
        • Use JSON as a complex parameter
    • Process Patterns
      • Process Route Implementation Pattern
      • Sub-Process or Process Route
    • DateTime
      • The Boomi datetime dilemma
      • Database and Flow
      • Groovy
      • Data Hub
      • Get Current Date
    • Groovy Script Patterns
      • Dynamic Document Properties
      • Dynamic Process Properties
      • Documents
    • Array Elements to Documents
  • MSPro Services
    • Intermediate Storage
      • Example Processes
        • Docs 01 - Update and Create
          • sub.SampleData.Invoice
        • 02 - Upsert and Get
    • Render Templates
  • Tips
Powered by GitBook
On this page
  1. Implementation Patterns
  2. Exception Handling

Basic Rules

Typically, you wrap a Try/Catch block around your functionality so that all unexpected situations flow down into the Catch block.

Try   --> whatever (unexpected) happens here
Catch --> will be handled here

Typically, you wrap a Try/Catch block around your functionality so that all unexpected situations flow down into the Catch block. There are some common patterns which are used independly of the programming environment or language.

  • DO use only one Try/Catch block per function / process

    • See also: Aggregating Exceptions

  • DO NOT handle unexpected situations as part of your business logic (for example, in a sub-process). Whenever you are coming across a situation in your logic, where you do not know how to recover you throw an Exception or let the Exception happen.

Delegating Exception Handling

While you might use multiple try/catch block only the top-level catch does the exception handling. "Lower" catch branches might implement some clean-up and terminate gracefully from the exception but they do not handle the exception itself, for example, by sending an e-mail. Normally, "lower" catch branches re-throw the exception to "bubble it up" to the highest handler.

Main Process 
  Try   --> subChild01()
  Catch --> Send E-Mail

subChild01()
  Try   --> Logic 
  Catch --> cleanup (close resources, set state etc.)
            re-throw exception --> will be caught in the Main Handler!

Anti-Pattern

WRONG: A sub-process catching and handling an exception: sending an e-mail.

RIGHT: Only the top-level process implements the exception handler (Catch block), while the sub-process let Exceptions happen.

This principle of delegating exception handling to parents is similar to real life:

If a child has a problem and it does not know how to solve it, it goes to its parents and asks them to handle it: simple escalation! (Imagine you let the children handle their problem themselves ...)

Last updated 6 months ago

A typical anti-pattern to handle an exception (send E-Mail) in the sub-process where it occurs