def exception_handler(exc):
 if isinstance(exc, APIException):
  headers = {}
  if getattr(exc, 'auth_header', None):
   headers['WWW-Authenticate'] = exc.auth_header
  if getattr(exc, 'wait', None):
   headers['X-Throttle-Wait-Seconds'] = ('%d' % exc.wait)
  if getattr(exc, 'project_data', None):
   headers['Taiga-Info-Project-Memberships'] = exc.project_data['total_memberships']
   headers['Taiga-Info-Project-Is-Private'] = exc.project_data['is_private']
  detail = format_exception(exc)
  return response.Response(detail, status=exc.status_code, headers=headers)
 elif isinstance(exc, Http404):
  return response.NotFound({'_error_message': str(exc)})
 elif isinstance(exc, DjangoPermissionDenied):
  return response.Forbidden({'_error_message': str(exc)})
 return None

def exception_handler ( exc ) : if isinstance ( exc , APIException ) : headers = { } if getattr ( exc , 'auth_header' , None ) : headers [ 'WWW-Authenticate' ] = exc . auth_header if getattr ( exc , 'wait' , None ) : headers [ 'X-Throttle-Wait-Seconds' ] = ( '%d' % exc . wait ) if getattr ( exc , 'project_data' , None ) : headers [ 'Taiga-Info-Project-Memberships' ] = exc . project_data [ 'total_memberships' ] headers [ 'Taiga-Info-Project-Is-Private' ] = exc . project_data [ 'is_private' ] detail = format_exception ( exc ) return response . Response ( detail , status = exc . status_code , headers = headers ) elif isinstance ( exc , Http404 ) : return response . NotFound ( { '_error_message' : str ( exc ) } ) elif isinstance ( exc , DjangoPermissionDenied ) : return response . Forbidden ( { '_error_message' : str ( exc ) } ) return None
returns the response that should be used for any given exception .