FIND YOUR NEXT FEW LINES

Results for “Functions & error handling”

Small, practical examples. Search by task or narrow things down below.

156 snippets foundClear filters
GoErrors & validation

Return a descriptive validation error

Return a descriptive validation error using a complete Go program with explicit sample inputs.

Go✓ Tested
GoErrors & validation

Wrap an error with context

Wrap an error with context using a complete Go program with explicit sample inputs.

Go✓ Tested
TypeScriptSafe data handling

Handle a result with a discriminated union

Separate success data from an error message.

discriminated union✓ Tested
GoFunctions & types

Accept a small behavior interface

Accept a small behavior interface using a complete Go program with explicit sample inputs.

Go✓ Tested
GoFunctions & types

Accept a variable number of arguments

Accept a variable number of arguments using a complete Go program with explicit sample inputs.

Go✓ Tested
RustFunctions & data types

Accept different types with a generic function

Accept different types with a generic function in a complete Rust program using the standard library.

Rust✓ Tested
PowerShellFunctions & parameter validation

Accept one typed value at a time from a pipeline

PowerShell: An advanced function uses process to handle each pipeline item.

PowerShell✓ Tested
PowerShellFunctions & parameter validation

Accumulate pipeline input across begin process and end

PowerShell: Keep initialization and final output separate from per-item work.

PowerShell✓ Tested
RustErrors & optional values

Add context to a parsing failure

Add context to a parsing failure in a complete Rust program using the standard library.

Rust✓ Tested
GoFunctions & types

Attach behavior to a struct

Attach behavior to a struct using a complete Go program with explicit sample inputs.

Go✓ Tested
C#Asynchronous work & URI handling

Await an asynchronous method result

C#: Use Task<T> for an async operation with a typed result.

C#✓ Tested
C#Asynchronous work & URI handling

Await multiple tasks while preserving result order

C#: Task.WhenAll returns results in the same order as the supplied tasks.

C#✓ Tested