Results for “failure”
Small, practical examples. Search by task or narrow things down below.
Detect an error inside a pipeline
Use pipefail to observe failure before the last pipeline command.
pipefail✓ Tested
Handle a terminating error
Catch conversion failures and produce a clear fallback.
try catch✓ Tested
Handle malformed JSON
C#: Catch JsonException for malformed JSON without swallowing unrelated failures.
C#✓ Tested
Inspect both successful and failed promise results
JavaScript: allSettled preserves input order and reports failures without rejecting the combined promise.
JavaScript✓ Tested
Inspect both successful and failed promise results
TypeScript: allSettled preserves input order and reports failures without rejecting the combined promise.
TypeScript✓ Tested
Perform cleanup even after an exception
C#: A finally block runs after a handled failure as well as after success.
C#✓ Tested
Raise and catch a domain-specific exception
Python: Give a validation failure its own exception type so callers can handle it narrowly.
Python✓ Tested
Rename a known file
C: The standard rename function reports failure through its return value.
C✓ Tested
Replace a text file with an atomic rename
Prepare new content beside the target before renaming it into place.
atomic write✓ Tested
Return a status separately from a calculated result
C: An output pointer lets a function return success or failure independently of its numeric result.
C✓ Tested
Return typed data from an async function
Await a Promise and handle failures explicitly.
async✓ Tested
Run cleanup after a caught exception
PowerShell: Use finally for cleanup that must occur after either success or failure.
PowerShell✓ Tested