Skip to main content

3 posts tagged with "exceptions"

exceptions tag description

View All Tags

Custom Classes for Python Exceptions: Extending the Error Toolkit

· 7 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Custom Classes for Python Exceptions: Extending the Error Toolkit​

Defining custom exception classes is a hallmark of professional-grade Python code. Instead of relying on generic built-in exceptions (like ValueError or TypeError) for every application-specific failure, custom exceptions provide clear, unambiguous signals about why an operation failed.

This article details the necessity, structure, and best practices for creating and utilizing your own exception hierarchy.

Python Exception Handling: Complete Guide to try-except, Propagation, Hierarchy, and Tracebacks

· 12 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Writing robust, fault-tolerant software in Python requires a solid understanding of how errors propagate, how Python's built-in exceptions are structured, and how to capture context-rich debugging information when failures occur.

This guide provides a comprehensive manual on exception handling in Python, detailing block flow control (try, except, else, finally), stack unwinding dynamics, the class inheritance hierarchy, multi-exception catch patterns, custom error design, context managers, and production logging strategies for tracebacks.

Dataclass AttributeError Solutions

· 9 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

The AttributeError is one of the most common exceptions in Python, indicating an attempt to access or set a class attribute that simply doesn't exist. When it occurs within the context of a @dataclass, it often points to a misunderstanding of how the decorator automatically generates methods like __init__ and __setattr__.

Here is a breakdown of the most frequent AttributeError scenarios involving dataclasses and the high-level solutions to resolve them.