Error Handling
Error handling is the discipline of deciding what a program does when an operation cannot complete as expected. It covers structured mechanisms such as exceptions, returned error values, and cleanup clauses, plus the judgment of when to handle, wrap, translate, or propagate a failure so problems stay visible and recoverable.
itSoftware engineering | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic: Error Handling
Error handling is the part of a program that decides what happens when normal completion is no longer available. That sounds like an afterthought until the first failure deletes context, leaks a resource, and reports the operational equivalent of something went wrong. At that point it becomes architecture with a traceback.
An error path is still a path. It has inputs, outputs, cleanup, and a caller that needs to decide what to do next. Exceptions move control to a handler. Returned values keep failure visible in the function result. Different languages prefer different mechanisms, and fighting the language usually produces more ceremony than clarity.
The useful question is where the right context exists. A library may know that parsing failed on a field. The application knows whether to skip the record, reject the file, or stop the workflow. Let errors pass through layers that cannot decide, but add context when a layer knows what it was trying to do.
Preserve causes. A database timeout can become a service unavailable error at an API boundary, but the original failure should remain attached for diagnosis. Cleanup is equally non-negotiable: files, locks, transactions, sockets, and temporary data need release paths for success, failure, and early return. The failure will not politely wait for a convenient branch.
Testing is where the discipline becomes real. Force the file open to fail. Force the dependency to time out. Force validation to reject input. Assert the type, message, cause, cleanup, and report. A suite that only tests successful work has not tested the program.
Start with the Practice Reference to classify failures and boundaries. Use the Exercise to design an import job's failure behavior. The Cheatsheet keeps mechanisms, cleanup, propagation, reporting, and testing in one view. The goal is not a program that never fails. The goal is a program that fails legibly, contains damage, and gives the next layer enough truth to act.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://docs.python.org/3/tutorial/errors.html
Supports
- try, except, else, and finally clause mechanics and how they control execution on failure
- Errors as outcomes to design for rather than surprises
- Quiz question 1
- The first study-path rationale
- https://go.dev/blog/errors-are-values
Supports
- The errors-as-values model and handling errors as ordinary data
- Checking errors with idiomatic code rather than a repeated branch
- Quiz questions 2 and 4
- The Go study-path rationale
- The 2015 timeline event codifying errors as values
- https://go.dev/blog/go1.13-errors
Supports
- Percent-w wrapping and the errors.Is and errors.As functions
- Inspecting wrapped error chains without losing the original
- Quiz question 5
- The 2019 timeline event adding error wrapping
- https://doc.rust-lang.org/book/ch09-00-error-handling.html
Supports
- Result for recoverable failures and panic for unrecoverable conditions
- The question-mark operator propagating errors from an enclosing function
- Quiz questions 7 and 10
- The Rust study-path rationale
- The 2016 timeline event stabilizing the question-mark operator
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Control_flow_and_error_handling
Supports
- JavaScript throw, try-catch-finally, the Error object, and error propagation
- The JavaScript study-path rationale
- https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/exceptions/
Supports
- try, catch, and finally execution semantics in C#
- Cleanup running whether the guarded region succeeds or throws
- Quiz question 3
- https://docs.oracle.com/javase/tutorial/essential/exceptions/
Supports
- Catch or declare checked exceptions and the throws clause
- Translating low-level exceptions into a layer's own vocabulary
- Quiz question 6
- The 1996 timeline event for Java checked exceptions
- https://docs.swift.org/swift-book/documentation/the-swift-programming-language/errorhandling/
Supports
- Swift throw, do-catch, try, and defer cleanup actions
- Quiz question 9
- The 2015 timeline event for Swift 2.0
- https://nodejs.org/api/errors.html
Supports
- Error propagation and interception in an event-loop runtime
- Error classes and how runtime errors surface to handlers
- https://en.wikipedia.org/wiki/Exception_handling
Supports
- The definition of an exception as a violated precondition
- Uncaught exceptions, top-level handlers, and runtime termination
- Error boundaries in React and Vue component hierarchies
- https://en.wikipedia.org/wiki/Exception_handling_(programming)
Supports
- PL/I ON conditions, Mesa resumption semantics, and C++ termination semantics
- The checked-exception design debate and catch-all handling
- Go panic and recover with recover restricted to deferred functions
- Rust Result and panic as an exception-free model
- Quiz question 8
- The 1964, c. 1979, c. 1990, 1998, and 2012 timeline events
- https://en.wikipedia.org/wiki/Checked_exception
Supports
- The origin of checked exceptions and the trade-offs of compile-time enforcement
- Quiz question 6
- The 1996 timeline event for Java checked exceptions
- https://www.python.org/doc/essays/stdexceptions/
Supports
- Python 1.5 converting exceptions from strings to classes
- The 1997 timeline event
- https://developer.apple.com/swift/blog/?id=29
Supports
- Swift 2.0 introducing error handling with throw, do-catch, and try
- The 2015 timeline event
- https://blog.rust-lang.org/2016/11/10/Rust-1.13.html
Supports
- Rust 1.13 stabilizing the question-mark operator for error propagation
- The 2016 Nov timeline event
- https://en.wikipedia.org/wiki/Mesa_(programming_language)
Supports
- Mesa as the Xerox PARC language whose exception model informed later design
- The c. 1979 timeline event
- https://en.cppreference.com/w/cpp/language/exceptions
Supports
- The C++ throw, try, and catch model and its history
- The 1998 timeline event
- https://github.com/avelino/awesome-go
Supports
- Discovery of the Error Handling section used to curate the Go awesome links
- https://github.com/sindresorhus/awesome-nodejs
Supports
- Discovery of stackman for the Node.js awesome link
- https://github.com/cockroachdb/errors
Supports
- The cockroachdb/errors Awesome Link rationale
- https://github.com/hashicorp/go-multierror
Supports
- The hashicorp/go-multierror Awesome Link rationale
- https://github.com/samber/oops
Supports
- The samber/oops Awesome Link rationale
- https://github.com/joomcode/errorx
Supports
- The joomcode/errorx Awesome Link rationale
- https://github.com/rotisserie/eris
Supports
- The rotisserie/eris Awesome Link rationale
- https://github.com/emperror/emperror
Supports
- The emperror/emperror Awesome Link rationale
- https://github.com/watson/stackman
Supports
- The watson/stackman Awesome Link rationale
- https://github.com/errsole/errsole.js
Supports
- The errsole.js Awesome Link rationale
- https://docs.rs/anyhow/latest/anyhow/
Supports
- The anyhow Awesome Link rationale
- https://docs.rs/thiserror/latest/thiserror/
Supports
- The thiserror Awesome Link rationale
- https://sentry.io
Supports
- Sentry landscape placement for error grouping, stack traces, and release correlation
- https://rollbar.com
Supports
- Rollbar landscape placement for real-time error and deploy correlation
- https://bugsnag.com
Supports
- Bugsnag landscape placement for error and release-health monitoring
- https://www.honeybadger.io
Supports
- Honeybadger landscape placement for exception reporting and uptime monitoring
- https://raygun.com
Supports
- Raygun landscape placement for crash reporting and diagnostics
- https://glitchtip.com
Supports
- GlitchTip landscape placement as a self-hostable, Sentry-compatible tracker
- https://www.datadoghq.com/error-tracking/
Supports
- Datadog Error Tracking landscape placement alongside logs, traces, and metrics
- https://newrelic.com/platform/errors-inbox
Supports
- New Relic Errors Inbox landscape placement for error triage with traces
- https://grafana.com/oss/faro/
Supports
- Grafana Faro landscape placement for open-source frontend error collection
- https://aws.amazon.com/cloudwatch/
Supports
- AWS CloudWatch landscape placement for log and metric error monitoring
- https://logrocket.com
Supports
- LogRocket landscape placement for session replay alongside errors
