Yes, once.
It was in a library that wrapped a third-party API. There was a dict that mapped API error codes to named exceptions, but if the code was unrecognised I didn’t want to show the user the KeyError.
exceptions = {
1: ForbiddenException(),
2: InvalidException(),
…
}
try:
raise exceptions[api_response.error_code]
except KeyError:
raise UnrecognisedErrorCode(api_response.error_code) from None