Results for “Errors & validation”
Small, practical examples. Search by task or narrow things down below.
Parse a hexadecimal integer
PowerShell: Convert.ToInt32 accepts an explicit base for a validated hexadecimal string.
PowerShell✓ Tested
Parse an integer without throwing on invalid input
PowerShell: TryParse reports conversion success separately from its output value.
PowerShell✓ Tested
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
Process the lines of an in-memory string
Java: Use String.lines to handle common line terminators without retaining them.
Java✓ Tested
Propagate a parsing error with question mark
Propagate a parsing error with question mark in a complete Rust program using the standard library.
Rust✓ 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
Quote a literal search term for a regex
C#: Regex.Escape prevents metacharacters in a literal term from changing the pattern.
C#✓ Tested
Read a quoted string containing spaces
C++: The quoted manipulator extracts a quoted field without splitting at internal spaces.
C++✓ Tested
Read an uncontrolled form with FormData
Read an uncontrolled form with FormData with a small React component and explicit browser behavior.
React✓ Tested
Reject NaN and infinite values
PowerShell: Double.IsFinite excludes numeric values unsuitable for ordinary bounded calculations.
PowerShell✓ Tested
Remove a known prefix safely
Python: Use removeprefix instead of lstrip when removing a literal prefix rather than a set of characters.
Python✓ Tested