🚀 DIGITAL TECH eBOOKS

Learn. Practice. Build.

Practical eBooks, interview questions, real-world projects and free learning resources for developers.

✓ Practical Content    ✓ Interview Focused    ✓ Real-World Examples

MuleSoft Error Handling: On Error Continue vs On Error Propagate

MuleSoft Error Handling: On Error Continue vs On Error Propagate – Complete Guide

Error handling is one of the most important skills for a MuleSoft developer. In a simple POC, you may only need to log an error and return a response. But in a production integration, you need to decide exactly what should happen when something goes wrong.

🇮🇳    https://payhip.com/mulesoftebooks/collection/mulesoft

🌎    https://mulesoftebooks.gumroad.com/

What happens when Salesforce is unavailable? What if a database query fails? What if an external API returns HTTP 500? Should the flow continue or should the error be sent back to the caller?

This is where MuleSoft error handling becomes extremely important. Two of the most commonly used error handlers are On Error Continue and On Error Propagate.




On Error Continue = Handle the error and continue successfully from the error handler.

On Error Propagate = Handle the error and propagate it to the calling flow or caller.

1. What Is Error Handling in MuleSoft?

Error handling is the mechanism used to control what happens when a Mule application encounters an error during message processing.

A typical integration may look like:

HTTP Request
     ↓
Validate Request
     ↓
Call Salesforce
     ↓
Transform Data
     ↓
Call Database
     ↓
Return Response

But what happens if Salesforce fails?

HTTP Request
     ↓
Validate Request
     ↓
Call Salesforce
     ↓
❌ Error
     ↓
Error Handler

The error handler determines what happens next.


2. What Is On Error Continue?

On Error Continue handles the error and considers the error-handling scope successful.

In simple terms:

"An error occurred, I handled it, and the flow can continue successfully."

For example:

Flow
 ↓
Process
 ↓
❌ Error
 ↓
On Error Continue
 ↓
Handled Response
 ↓
Flow completes successfully

This can be useful when the business requirement allows the application to recover from the error and return a controlled response.


3. What Is On Error Propagate?

On Error Propagate handles the error and then propagates the error to the calling flow or caller.

In simple terms:

"An error occurred, I handled it here, but the failure should still be propagated."

The simplified flow looks like:

Flow
 ↓
Process
 ↓
❌ Error
 ↓
On Error Propagate
 ↓
Error Propagated
 ↓
Caller receives failure

4. On Error Continue vs On Error Propagate

Feature On Error Continue On Error Propagate
Error handled Yes Yes
Error considered handled Yes No, it propagates
Typical behavior Continue successfully Propagate failure
Useful for Controlled recovery Failure propagation

5. Real-World Example: Salesforce Failure

Imagine an API receives an order and calls Salesforce.

Client
  ↓
Order API
  ↓
Salesforce
  ↓
❌ Salesforce unavailable

If Salesforce is a mandatory system for the transaction, you probably do not want to hide the failure.

In that situation, On Error Propagate may be appropriate.

Salesforce Failure
       ↓
On Error Propagate
       ↓
Log Error
       ↓
Return Error Response

The caller knows that the operation was not successfully completed.


6. When Can On Error Continue Be Useful?

Consider an integration where a non-critical operation fails.

For example:

Main Business Transaction
        ↓
Save Order
        ↓
Success
        ↓
Send Optional Notification
        ↓
❌ Notification Failed
        ↓
On Error Continue
        ↓
Return Successful Order Response

If the notification is not critical to the business transaction, the application may be designed to continue after handling that failure.

The correct choice always depends on the business requirement.


7. Global Error Handler

MuleSoft applications can also use a global error handler to centralize error-handling behavior.

A simplified architecture could look like:

API Flow
   ↓
Business Logic
   ↓
Connector
   ↓
❌ Error
   ↓
Global Error Handler
   ↓
Log / Transform / Propagate

Centralizing common error-handling logic can help maintain consistency across multiple flows.


8. Error Types Matter

Not every MuleSoft error should be handled in exactly the same way.

Examples of errors you may encounter include:

  • HTTP connectivity errors
  • HTTP response errors
  • Database errors
  • Validation errors
  • Transformation errors
  • Security errors
  • Timeouts

A production application should classify errors according to the business and technical requirements.


9. Custom Error Response

An API should generally avoid exposing internal implementation details to the client.

For example, instead of returning an internal technical exception:

DatabaseConnectionException:
Connection pool exhausted...

you might return a controlled API response such as:

{
  "status": 500,
  "message": "Unable to process the request",
  "correlationId": "8F92A21"
}

This provides a cleaner API contract while allowing internal logs to contain the technical details required for troubleshooting.


10. Error Handling + Correlation ID

Correlation IDs are extremely useful when troubleshooting production integrations.

Request
   ↓
Correlation ID = 8F92A21
   ↓
Salesforce
   ↓
Database
   ↓
External API
   ↓
❌ Error

The same correlation ID can help operations teams trace the transaction through logs and monitoring systems.


11. Error Handling + Retry

Retry and error handling often work together.

For example:

External API
     ↓
Temporary Failure
     ↓
Retry
     ↓
Success?
   /      \
 YES       NO
  ↓         ↓
Continue   Error Handler
             ↓
          DLQ / Alert / Error Response

The important point is to retry only errors that are appropriate for retry. A permanent business error should not necessarily be retried repeatedly.


12. Error Handling in Batch Processing

Batch integrations introduce another important consideration.

Imagine processing 10,000 records:

10,000 Records
      ↓
Batch Processing
      ↓
Record 1 → Success
Record 2 → Success
Record 3 → Failure
Record 4 → Success
...

The application may need to capture failed records separately instead of losing information about which records failed.

Possible recovery approaches include:

  • Logging failed records
  • Storing failed records
  • Retrying eligible records
  • Sending failed messages to a DLQ
  • Creating a recovery process

13. Common Error Handling Mistakes

❌ Mistake 1 — Using On Error Continue Everywhere

If every error is converted into success, serious production failures may be hidden from callers and monitoring systems.

❌ Mistake 2 — Propagating Every Error

Some non-critical operations may be safely handled without failing the entire business transaction.

❌ Mistake 3 — Exposing Internal Errors

Avoid returning sensitive technical implementation details directly to API consumers.

❌ Mistake 4 — No Correlation ID

Without transaction identifiers, troubleshooting distributed integrations can become much harder.

❌ Mistake 5 — No Recovery Strategy

Handling an error is not enough. You should also know how the failed transaction will be recovered.


14. MuleSoft Interview Question

What is the difference between On Error Continue and On Error Propagate?

Answer: On Error Continue handles the error and allows the error-handling scope to complete successfully, while On Error Propagate handles the error but propagates it to the calling flow or caller.

The choice depends on whether the business transaction should be considered successful after the error is handled.

Easy way to remember:

On Error Continue → Handle + Continue
On Error Propagate → Handle + Propagate

15. Real-World MuleSoft Error Handling Architecture

                    API Request
                         ↓
                    Mule Flow
                         ↓
                  Business Logic
                         ↓
                  External System
                         ↓
                       Error
                         ↓
                 Identify Error Type
                         ↓
                  Is It Recoverable?
                    /          \
                  YES           NO
                   ↓             ↓
                Retry        Error Handler
                   ↓             ↓
               Success?      Log + Response
                /    \
              YES     NO
               ↓       ↓
           Continue   DLQ / Alert

🚀 Final Takeaway

Good MuleSoft error handling is not simply about catching exceptions. It is about designing what should happen after something fails.

Before implementing an error handler, ask:

  • What type of error occurred?
  • Is the error temporary or permanent?
  • Should the operation be retried?
  • Should the business transaction continue?
  • Should the error be propagated?
  • Should the failed message go to a DLQ?
  • How will the transaction be monitored?
  • How will the failure be recovered?
Error Handling + Retry + Logging + Monitoring + Recovery

Build MuleSoft integrations that are easier to operate and recover.

Understanding On Error Continue vs On Error Propagate is essential for MuleSoft developers, especially when working on production integrations and senior-level MuleSoft interviews.


📚 Want More MuleSoft Real-World Scenarios?

I've created practical MuleSoft eBooks covering 500+ interview questions, real-world integration scenarios, DataWeave, MUnit, troubleshooting, error handling, deployment, and enterprise integration patterns.

👉 MuleSoft Interview Mastery — 500+ Questions, Real-World Scenarios & Practical Solutions →


Follow Digital Tech eBooks for more MuleSoft tutorials, DataWeave examples, interview questions, architecture patterns, and real-world integration scenarios.


🇮🇳    https://payhip.com/mulesoftebooks/collection/mulesoft

🌎    https://mulesoftebooks.gumroad.com/

Post a Comment

0 Comments