Skip to content
tezvyn:

Error Handling

56 bites tagged Error Handling — interview questions with model answers, and 60-second explainers.

Node.js & Express1 min read

How do you handle errors across piped streams safely?

Pipe connects streams but errors don't auto-propagate, must listen on each stream. Use pipeline() helper for auto-cleanup. stream lifecycle and error propagation understanding.

TypeScript & Web APIs1 min read

Promise .catch() versus async/await try...catch

.catch() handles rejection for all preceding chain steps and reads functionally; try/catch reads synchronously and can scope errors per await, but only catches awaited rejections. Async error-handling models.

React Native1 min read

Robust network error handling strategy

Classify errors as 4xx, 5xx, or connectivity; retry transient failures with backoff, surface actionable messages, and check NetInfo. differentiated error handling. one generic catch that retries everything, including 400s.

Product Strategy1 min read

Designing an API for power vs novice personas

Power users want control, batching, and precise errors; novices want defaults, guardrails, and guidance; both want consistency. Whether personas drive concrete API tradeoffs.

Node.js & Express1 min read

Pinpointing validation errors in nested request data

Use schema validation that reports a path, collect all errors not just the first, return a 400 with field paths and messages. structured error reporting for nested input.

Node.js & Express1 min read

Handling uncaughtException and unhandledRejection

Listen on process for uncaughtException and unhandledRejection, log the error, stop accepting new work, drain in-flight requests, then exit non-zero for a supervisor to restart. process-level last-resort error handling.

Node.js & Express1 min read

Operational versus programmer errors in Node.js

Operational errors are expected runtime conditions you handle and respond to; programmer errors are bugs that may corrupt state, so you log and gracefully restart. error classification and recovery policy.

Node.js & Express1 min read

Custom Error classes and centralized handling

Custom Error subclasses carry a statusCode and flag, the central handler inspects instanceof or statusCode to set the HTTP code and JSON shape, defaulting unknown errors to 500. structured error design.

Node.js & Express1 min read

Propagating async errors to Express error handlers

Express does not auto-catch rejected promises, so catch and call next(err), or wrap handlers in an asyncHandler that forwards rejections; Express 5 awaits handlers automatically. async error forwarding.

Node.js & Express1 min read

Centralized error handling in an Express API

A final four-arg error middleware, an asyncHandler wrapper to funnel promise rejections via next, a custom error class with statusCode, returning uniform JSON. designing one error path.

Node.js & Express1 min read

404 vs 500: missing resource vs server failure

A missing resource returns 404 Not Found (client asked for something absent); a database failure returns 500 Internal Server Error (server-side fault). 4xx versus 5xx semantics.

Node.js & Express1 min read

Express error-handling middleware signature

(err, req, res, next) with err first, identified by arity, placed last after all routes. recognizing the four-argument signature. omitting the err parameter or registering it before the routes it should catch.

Node.js & Express1 min read

Centralized error-handling middleware

Error middleware takes four args err, req, res, next, is defined last, and runs when next(err) is called or sync errors throw. Express error flow. omitting the err parameter so Express treats it as normal middleware.

Node.js & Express1 min read

Promise.all vs Promise.allSettled

All rejects on the first failure; allSettled always fulfills with a status/value or reason per input. Use allSettled when partial success is acceptable. choosing fail-fast vs collect-all.

Node.js & Express1 min read

Comparing the three async error-handling styles

Callbacks pass err as first arg; Promises route errors to catch; async/await uses try/catch; an unhandled rejection can crash the Node process. fluency across async error styles.

Node.js & Express1 min read

Handling async errors in Express middleware

Await inside try/catch and call next(err) on failure, or wrap the handler in an async error adapter; never let a rejected Promise go uncaught. routing async errors into Express.

LLMs & Generative AI2 min read

Handling a 401 error in an LLM agent's tool call

Catch the tool error, return a structured observation to the LLM, and distinguish recoverable retries from terminal failures needing re-plan or escalation. Robust agent error handling.

iOS & Swift1 min read

do-try-catch versus Optional return types

Throwing functions with do/try/catch convey why something failed via typed Error values; Optionals only say success or absence. Use throws when the caller needs the reason. error modeling choices.

Go & Rust2 min read

anyhow versus thiserror in Rust error handling

Anyhow gives one opaque dynamic error type for applications where you mostly propagate and report; thiserror derives concrete typed enums for libraries so callers can match on variants. idiomatic error-design judgment.

Go & Rust2 min read

Go if err != nil versus Rust's ? operator

Go's explicit checks are verbose but make every error site visible; Rust's ? propagates concisely while still forcing the error into the type, reducing boilerplate. judgment on error-handling ergonomics.

Go & Rust2 min read

Go (T, error) versus Rust Result for error handling

Go returns a separate error value you may ignore; Rust wraps success or error in one Result enum the compiler forces you to handle. Go favors simplicity, Rust favors compile-enforced safety. understanding of explicit error models.

Go & Rust2 min read

Handling Result and errors in a Rust web handler

Handler returns Result, the ? operator early-returns errors, a custom error type implements IntoResponse to map to 500, success returns 200 with data. Result-based error handling in web handlers.

Go & Rust1 min read

Structuring a Go CLI that fetches a URL

Parse args with the flag package, http.Get the URL, check err and status, defer resp.Body.Close, copy body to stdout, exit non-zero on failure. basic Go CLI, HTTP, and error handling.

Go & Rust2 min read

Building a safe Rust wrapper over an unsafe C API

Hide extern calls behind a safe module, own the resource in a struct with Drop calling the C free, return Result mapping C error codes, use NewType/NonNull and PhantomData. FFI encapsulation patterns.

Get Error Handling bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

Open testing — you’ll join as an early tester.