Error type
An error type is a data type whose values represent failure conditions and may carry information used to identify, report, or handle them.
Refactoring to Rust
A custom error type is a programmer-defined type that represents the distinct failure conditions an operation can return.
- How it is used
- Uses custom errors to distinguish failures in Rust functions and keep calculator logic separate from its C interface.
- How deep it goes
- Works through enum variants, Result handling, propagation and API visibility, and mentions error conversion and Display.
- Examples
- Uses a negative-number FizzBuzz error and calculator errors for invalid numbers and empty-stack pops.
- What you can do after
- Builds a custom Rust error enum, returns and forwards its variants, and exposes it in a public API.
Rust Servers, Services, and Apps
A custom error type is a programmer-defined Rust type that represents application-specific failures and can unify multiple underlying error types.
- How it is used
- Unifies failures across database access and web handlers so Actix can return meaningful HTTP errors.
- How deep it goes
- Works through enum variants, From conversions, ResponseError status and body methods, and handler return types.
- Examples
- Uses a parsing-and-file-I/O mismatch, a course-insertion handler, and a registration error enum.
- What you can do after
- Build it from scratch for an Actix service, propagate database failures, and return category-appropriate HTTP responses.
Read how Rust Servers, Services, and Apps explains error type →
Go in Action, Second Edition
An error type is Go's interface type for representing failed or abnormal operation results through an Error method.
- How it is used
- Uses error values to make failures explicit in function results and handle them close to the operation.
- How deep it goes
- Explains the interface and return convention, then develops a custom type that records missing keys.
- Examples
- Uses a key/value store and a bulk lookup that collects missing keys in a custom error.
- What you can do after
- Build a custom error type and handle or inspect returned errors with Go’s errors package.
Learn Go with Pocket-Sized Projects
A custom error is an application-defined error value or type representing a specific failure condition.
- How it is used
- Uses typed and custom errors to carry domain failures across business, repository, and gRPC API layers.
- How deep it goes
- Defines error fields and Error methods, demonstrates validation and status conversion, and tests ErrorAs without exploring broader error hierarchies.
- Examples
- Uses InvalidInputError for blank habit names and a not-found repository error when ticking an unknown habit.
- What you can do after
- Apply it via Go error types, errors.Is, ErrorAs, and gRPC status conversion to validate inputs and expose stable failures.
Read how Learn Go with Pocket-Sized Projects explains error type →
Clean Applications with Hexagonal Architecture
An error represented by a distinct type so that its category and handling behavior are explicit.
- How it is used
- Makes command and query failures part of the application contract instead of leaving them implicit in exceptions.
- How deep it goes
- Defines an Error hierarchy and demonstrates validation aggregation and handler propagation without detailing the hierarchy's full design.
- Examples
- Uses PublishArticleCommand validation for missing IDs and a publication handler that chains repository and domain operations.
- What you can do after
- Apply it via Vavr's Either to return explicit failures from commands and use-case handlers.
Read how Clean Applications with Hexagonal Architecture explains error type →
Go in Practice, Second Edition
- How it is used
- Uses custom error types to preserve failure details and let callers choose handling based on the specific error.
- How deep it goes
- Explains the error interface, implements structured parser and HTTP errors, and stops short of broader type-system internals.
- Examples
- Demonstrates ParseError diagnostics and conversion of non-success HTTP responses into structured errors.
- What you can do after
- Build custom Go errors that carry structured diagnostics and handle unexpected HTTP responses explicitly.
Read how Go in Practice, Second Edition explains error type →
Also covered in
- Rust in Action: Systems programming concepts and techniques
- Idiomatic Rust
- Go by Example
- Code Like a Pro in Rust
What to know first
- result typeA result type represents the outcome of an operation as either a successful value or a failure, often carrying information about either outcome.
- DebugDebug is a Rust standard-library formatting trait for producing programmer-oriented representations of values.
- enumAn enum is a type whose values are selected from a finite set of named alternatives.
- handlerA handler is a software routine or component invoked to process an event, request, message, or other input.
Related concepts
- failureimplements · A failure is an event or condition in which an operation, component, or system does not achieve an expected result or perform its intended function.
- interfacekind of · An interface is a contract or boundary that specifies the operations, members, or data shape a type or component exposes, without prescribing its complete implementation.
- Errorimplements · std::error::Error is Rust’s standard-library trait for types that represent errors and can provide descriptions and source-error relationships.
- From traitused by · From is Rust’s standard-library trait for infallibly converting a value of one type into another type.
- outputproduces · An output is a result, value, message, or action produced or returned by a system or operation in response to input or a request.
Questions about error type
What is error type?
An error type is a data type whose values represent failure conditions and may carry information used to identify, report, or handle them.
Which Manning books explain error type?
Refactoring to Rust, Rust Servers, Services, and Apps, Go in Action, Second Edition, Learn Go with Pocket-Sized Projects, Clean Applications with Hexagonal Architecture and Go in Practice, Second Edition.
What should I know before learning error type?
Manning books that teach error type usually introduce result type, Debug, enum and handler first.
What is error type a kind of?
Error type is a kind of interface. An interface is a contract or boundary that specifies the operations, members, or data shape a type or component exposes, without prescribing its complete implementation.
What are the parts of error type?
Error type includes error method.
What is error type also called?
Error type is also called custom error.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.





