The implementation chosen (try..except) is less clear than checking for the pattern.
But that error being not frequent., 2 times so far, I prefer avoidinging the string comparison.
Shout out if you disagree ;)
Related https://sentry.softwareheritage.org/share/issue/518b76d7d7d244f8b88d1757599035b2/