Тема: 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
Асинхронная функция превращает throw в отклонение промиса, а await повторно возбуждает ошибку; у каждого отклонения должен быть ответственный обработчик. Оборачивайте только операции, после которых можете восстановиться, не оставляйте промисы без обработки, используйте 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