Error Bubbling
Error bubbling is the process by which an error generated in a low-level contract or function is propagated up through the call stack to the initiating contract. When a function calls another function that reverts, the revert signal passes through the stack until it reaches the initial entry point.
This allows the top-level contract to handle or catch the failure and respond accordingly. In the context of DeFi, this is crucial when one protocol interacts with another to execute a trade.
If the underlying exchange fails, the calling protocol must receive that signal to cancel its own internal state changes. Proper error bubbling ensures that failures are not ignored and that the system remains in a predictable state.
It allows for hierarchical error management, where different levels of the stack can perform cleanup tasks before the transaction finally reverts.