code: def api_exception(e):
      
      _, _, exc_traceback = sys.exc_info()
      tb = '\n'.join(traceback.format_tb(exc_traceback))
      return {
          400: BadRequestError,
          401: UnauthorizedError,
          403: ForbiddenError,
          404: NotFoundError,
          405: MethodNotAllowedError,
          409: ConflictError,
          410: GoneError,
          422: UnprocessibleEntityError,
          429: TooManyRequestsError,
          500: InternalServerError,
          503: ServiceUnavailableError,
          504: ServerTimeoutError,
      }.get(e.status, DynamicApiError)(e, tb)
docs: Returns the proper Exception class for the given kubernetes.client.rest.ApiException object
      https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#success-codes