テーマ: error-handling
-
PowerShell error handling for admin scripts: terminating errors, $ErrorActionPreference and $LASTEXITCODE
PowerShell has two error classes that behave differently in a script: terminating errors that try/catch can stop, and non-terminating errors that only $ErrorActionPreference or -ErrorAction can turn into a stop. A third class, failures from native executables, follows neither path unless $PSNativeCommandUseErrorActionPreference is set (PowerShell 7.4+, experimental in 7.3).
-
Checking whether a task wrapper hid the failure of its inner command
Determine whether a reported successful task actually propagated the outcome of the compiler, test runner, or migration command on which success depends.
-
Go のエラー処理:%w によるラップ、errors.Is、errors.As
Go の関数はエラーを通常の値として返します。fmt.Errorf と %w 書式指定子で文脈を加え、元のエラーにたどれるようにします。その後、文字列比較や == ではなく、センチネル値には errors.Is、型には errors.As(またはジェネリックな errors.AsType)を使ってチェーンを調べます。
-
Promise と async/await のエラーを処理する
async 関数は throw を拒否に変え、await はそのエラーを再び送出する。すべての拒否には処理責任を持つ箇所が必要である。復旧できる処理だけを囲み、Promise を放置せず、部分的な失敗を許容できる場合は allSettled を使い、最後の備えとして unhandledrejection ハンドラーを登録する。
-
Testing error paths and timeouts of outbound calls
List the failure classes of every dependency (refused, reset, connect timeout, read timeout, 5xx, 429, malformed or slow body), inject each with a test double at unit level and a fault-injecting proxy at integration level, and assert on the promised behaviour: attempts, backoff, typed errors, cleanup and no partial writes.
-
Result, Option and the ? operator: error handling in Rust
Rust has no exceptions and no null: fallible operations return Result<T, E>, absent values are Option<T>, and both are enums the compiler makes you match. The ? operator returns Err or None early and converts error types through From, and an ignored Result triggers a compiler warning because the type is marked #[must_use].
機械可読: JSON