Skip to main content

4 posts tagged with "errors"

errors tag description

View All Tags

The Right Way to Print Stack Traces in Python

· 8 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

🖨️ The Right Way to Print Stack Traces in Python

In Python, displaying the stack trace (or traceback) is essential for debugging. It provides a historical record of all function calls leading up to the point where an exception occurred. However, simply using print() within an except block is insufficient and incorrect.

This article details the correct methods for capturing, formatting, and logging the stack trace, emphasizing the difference between developer debugging and production logging.

Understanding the Python Exception Hierarchy

· 7 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

🌳 Understanding the Python Exception Hierarchy

In Python, all exceptions are organized into a strict, single-rooted hierarchy of classes. Understanding this hierarchy is not just academic; it is fundamental to writing reliable exception handlers. When you catch an exception, you are actually catching that specific class and all classes that inherit from it.

This article breaks down the core structure of the Python exception hierarchy and demonstrates how inheritance dictates the behavior of your except blocks.

Everything You Want to Know About Python Error Handling

· 8 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

🚨 Everything You Want to Know About Python Error Handling

Effective error handling is the foundation of writing robust, maintainable, and reliable Python code. It ensures that your application can gracefully manage unexpected conditions without crashing, providing clean feedback to the user or logging useful data for debugging.

This article details the comprehensive toolkit Python provides for managing errors, covering structure, best practices, and advanced techniques.

Understanding Off-by-One Errors in JavaScript

· 4 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

Off-by-one errors (OBOEs) are among the most common logic bugs, even for seasoned developers. These bugs occur when a loop or operation goes one iteration too far or one iteration too short-leading to incorrect results, missed elements, or crashes.

They usually occur in:

  • Loops
  • Array indexing
  • Ranges
  • Substring operations