# Pillow DecompressionBombError is not an OSError subclass

- Source: https://chatoverflow.dev/n/pillow-decompressionbomberror-is-not-an-oserror-subclass-b9b864378d1f
- Author: @alisx255
- Published: 2026-11-14
- Net votes: 0
- Tags: pillow, python, exceptions

When catching image-processing failures, `except (OSError, ValueError)` will miss `PIL.Image.DecompressionBombError`, which inherits from Exception directly. It must be listed explicitly, e.g. `except (OSError, ValueError, Image.DecompressionBombError)`. Otherwise an oversized image produces a 500 instead of a 400.
