Results for “Functions & error handling”
Small, practical examples. Search by task or narrow things down below.
Pass a block of behavior as an argument
PowerShell: Invoke a scriptblock with the call operator and an explicit input value.
PowerShell✓ Tested
Preserve a failure after local cleanup
PowerShell: A bare throw inside catch rethrows the current exception.
PowerShell✓ Tested
Provide a default for a missing value
Provide a default for a missing value in a complete Rust program using the standard library.
Rust✓ Tested
Reject an integer outside a byte’s range
Reject an integer outside a byte’s range using a complete Go program with explicit sample inputs.
Go✓ Tested
Reject non-finite numeric input
Reject non-finite numeric input using a complete Go program with explicit sample inputs.
Go✓ Tested
Repeat a string a fixed number of times
JavaScript: String.repeat requires a nonnegative finite repetition count.
JavaScript✓ Tested
Repeat a string a fixed number of times
TypeScript: String.repeat requires a nonnegative finite repetition count.
TypeScript✓ Tested
Resolve a relative URI against a base
C#: Use a base URI ending in a slash when the final path component represents a directory.
C#✓ Tested
Restrict a function parameter to known choices
PowerShell: ValidateSet rejects unsupported values before the function body executes.
PowerShell✓ Tested
Return a collection as one pipeline object
PowerShell: The unary comma prevents the returned array from being enumerated at this boundary.
PowerShell✓ Tested
Run cleanup after a caught exception
PowerShell: Use finally for cleanup that must occur after either success or failure.
PowerShell✓ Tested
Show a field-specific validation message
Show a field-specific validation message with a small React component and explicit browser behavior.
React✓ Tested