custom exception

An exception class you define yourself, usually in two lines by subclassing Exception, to name an error specific to your program.

In more detail

class EmptyDataError(Exception): pass is enough. It earns its place when callers need to catch your error separately from built-in ones; otherwise reuse ValueError or another built-in.

Example

class EmptyDataError(Exception):
    pass

Related terms

Taught in

References

Certification courses