Results for “error handling”
Small, practical examples. Search by task or narrow things down below.
Parse JSON into an object
Access a named field in a JSON document.
JSON✓ Tested
Read a big-endian integer from bytes
Java: Set a byte order explicitly when handling a binary protocol.
Java✓ Tested
Read a nested optional value
Avoid dereferencing a missing nested object.
optional chaining✓ Tested
Read a stream again from its beginning
C: rewind returns a seekable stream to offset zero and clears its error and EOF indicators.
C✓ Tested
Rename a known file through filesystem
C++: filesystem::rename reports an error by exception when the operation fails.
C++✓ Tested
Update an object with a readonly input
Create a changed copy while retaining the original.
readonly✓ Tested
Validate a complete floating-point input
C: strtod exposes both the stopping position and range errors; reject nonfinite results when required.
C✓ Tested
Validate an argument at a method boundary
C#: ThrowIfNegative gives callers an explicit argument error for an invalid range.
C#✓ Tested
Validate an unknown value with a type guard
Check a field before treating unknown data as a typed object.
unknown✓ Tested