1

I am new to mulesoft and while studing it i strugle to understand why on module "onErrorPropagate" the error is being rethrown after executing the scope.

can you explain the benefits?

Ion Utale
  • 551
  • 1
  • 9
  • 22

2 Answers2

1

An on-error-propagate will rollback any transactions, execute, and use that result to rethrow the existing error––meaning its owner will be considered as “failing.”

The best use is in a layered system, to allow each layer to do its own small part of an error response.

If you are familiar with Java you can think of it as catching the exception and re-throwing it. For example, sometimes you want to do something with the error yourself, but still want to propagate it upwards for higher levels to deal with.

You could add logging in a specific flow for the error but then leave it to the parent flows to actually deal with the exception.

Ryan Carter
  • 11,441
  • 2
  • 20
  • 27
1

The "onErrorPropagate" propagates (rethrows) the error to the parent flow (or the global error handler if it's already reached the main flow).

This can be usefull in a few cases. Say you have some flow specific error handling (e.g. if something goes wrong, set a default payload). Then you propagate this error to the next level where you have your Global error handler that, say, stores some info in a QA database.

You don't want to have that database connector in every single error handler. In this way you can achieve a 'java inherritance' like structure, for your errors.

Side note: if you want your error to only be handled and do nothing further, you can use "onErrorContinue"