onFailure
OnFailure is a term used in asynchronous programming to designate a callback or handler that is invoked when an operation fails to complete successfully. It is commonly paired with success or completion callbacks and is designed to allow implementers to react to errors, perform cleanup, or initiate retries. The exact form of onFailure and the data it receives vary by language and library, but it typically conveys an error condition via an exception, error object, or error code.
In practice, onFailure is used in networking, file I/O, background tasks, and other asynchronous flows. For example,
Design considerations include providing meaningful error information, preserving stack traces, avoiding leakage of sensitive data, and
In library design, onFailure often coexists with onSuccess or onComplete, and developers should document the expected