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
Intro
Error Handling
Every operation has preconditions: conditions under which it can complete normally. Error handling is what your program does when those conditions are violated. An error is not an accident — it is an outcome the code has to account for, and the discipline is deciding that account in advance instead of discovering it at runtime.
The goal is a program that fails clearly, cleans up after itself, and gives the next layer enough information to act. That means choosing the right mechanism, preserving context as an error moves up, and testing the failure paths with the same care as the happy path.
Errors are conditions, not surprises
An exception or an error value represents a violated precondition: an invalid argument, a missing file, an unavailable resource, or a routine that detected a condition requiring special handling. What counts as an error is a design decision. Division by zero can abort, return a sentinel value, or raise an exception — each choice changes what callers must do.
The word "exception" does not mean "rare". A lookup that misses its key may happen more often than a hit. Treat the error path as a first-class path: it has inputs, outputs, and behavior you can test.
Two families of mechanisms
Languages broadly offer two models, and some offer both:
Continue the course
This section is part of the paid course.
See pricing to subscribe, or log in if you already have access.
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
