liveBook · Manning

User-defined exception

A user-defined exception is a programmer-defined exception type representing an application-specific error or abnormal condition.

How 3 Manning books explain it

The Quick Python Book, Fourth Edition

A custom exception is a programmer-defined exception class representing an application-specific abnormal condition.

How it is used
Represents application-specific exceptional conditions that code can raise and handle.
How deep it goes
Works through definition, raising, catching, and arguments; defers detailed design of exception subhierarchies.
Examples
Uses MyError with a printed message and multiple arguments, plus EmptyStringError in text cleaning.
What you can do after
Build it from scratch: define an Exception subclass, raise it, catch it, and decide whether a dedicated type is worthwhile.

Read how The Quick Python Book, Fourth Edition explains user-defined exception →

The Art of Code

A custom exception is an application-defined exception type whose name and structure represent a specific failure condition.

How it is used
Translates technical failures into meaningful domain failures at business, API, and user-facing boundaries.
How deep it goes
Explains naming, immutable context, wrapping, and cause preservation, without defining exception runtime internals.
Examples
Uses data parsing to wrap NumberFormatException as DataProcessingException, with a Python exception-chaining counterpart.
What you can do after
Apply it to name domain failures and retain original causes for useful diagnostics.

Read how The Art of Code explains user-defined exception →

Python How-To

A custom exception is a programmer-defined exception type used to represent application-specific error conditions.

How it is used
Uses named, package-specific failures to communicate application conditions and support callers handling library errors.
How deep it goes
Explains inheritance, package hierarchies, custom messages, __str__, raising, catching, and documentation, without detailing exception internals.
Examples
Demonstrates TaskierError, FileExtensionError, CSV validation, upload_file, and custom handling for tasks.csv and tasks.docx.
What you can do after
Build package-specific exception hierarchies, raise informative failures, catch named conditions, and document possible exceptions.

Read how Python How-To explains user-defined exception →

Related concepts

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.