⬅︎ Back to Cope with JSONDecodeError in requests.get().json() in Python 2 and 3
JSONDecodeError is a subclass of ValueError, so I'd expect a simple `except ValueError:` to work fine on both versions.
Cool! I didn't know that. But it makes perfect sense. Granted there are benefits to using specific exceptions to avoid "over swallowing" errors if you cover multiple lines.
Comment
JSONDecodeError is a subclass of ValueError, so I'd expect a simple `except ValueError:` to work fine on both versions.
Replies
Cool! I didn't know that. But it makes perfect sense.
Granted there are benefits to using specific exceptions to avoid "over swallowing" errors if you cover multiple lines.