liveBook · Manning

Custom exception

A custom exception is a programmer-defined exception type that represents 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
Distinguishes application-specific conditions for exception handling and library interfaces.
How deep it goes
Demonstrates definition, raising, catching, and argument access; outlines custom exception hierarchies without developing them in detail.
Examples
Uses MyError with message and tuple arguments, plus EmptyStringError in a text-cleaning function and package.
What you can do after
Build custom exception classes from scratch, raise and catch them, and access their arguments.

Read how The Quick Python Book, Fourth Edition explains custom 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 errors at business, API, or user-facing boundaries.
How deep it goes
Demonstrates defining and throwing custom exceptions, including immutable captured data and preservation of the original cause.
Examples
Uses data parsing failures and invalid order IDs to illustrate named exceptions.
What you can do after
Build a custom exception from scratch to name a failure and preserve its original cause.

Read how The Art of Code explains custom 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 custom exception →

Also covered in

What to know first

Related concepts

Questions about custom exception

What is custom exception?

A custom exception is a programmer-defined exception type that represents an application-specific error or abnormal condition.

Which Manning books explain custom exception?

The Quick Python Book, Fourth Edition, The Art of Code and Python How-To.

What should I know before learning custom exception?

Manning books that teach custom exception usually introduce exception, ValueError, floating-point arithmetic and tax first.

What kinds of custom exception are there?

Kinds of custom exception include base exception class.

What is custom exception a kind of?

Custom exception is a kind of exception. An exception is a runtime signal representing an abnormal condition that interrupts ordinary program flow and can be handled or propagated.

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.