def exception_handler(exc): """ Add treeherder-specific exception handling to the rest framework Mostly a conversion of treeherders ORM exceptions to drf APIExceptions """ import traceback full_message = traceback.format_exc() logger.error(exc) logger.error(full_message) if isinstance(exc, DatasetNotFoundError): exc = ResourceNotFoundException( "No project with name {0}".format(exc.project) ) if isinstance(exc, ObjectNotFoundException): exc = ResourceNotFoundException( "{0} object not found using: {1}".format( exc.table, unicode(exc.extra_info))) response = drf_exc_handler(exc) if response is None: msg = {"detail": unicode(exc)} if settings.DEBUG: msg["traceback"] = full_message response = Response(msg, status=500) return response
def exception_handler(exc): """ Add treeherder-specific exception handling to the rest framework Mostly a conversion of treeherders ORM exceptions to drf APIExceptions """ import traceback full_message = traceback.format_exc() logger.error(exc) logger.error(full_message) if isinstance(exc, DatasetNotFoundError): exc = ResourceNotFoundException("No project with name {0}".format( exc.project)) if isinstance(exc, ObjectNotFoundException): exc = ResourceNotFoundException( "{0} object not found using: {1}".format(exc.table, unicode(exc.extra_info))) response = drf_exc_handler(exc) if response is None: msg = {"detail": unicode(exc)} if settings.DEBUG: msg["traceback"] = full_message response = Response(msg, status=500) return response
def exception_handler(exc, context): """ Add treeherder-specific exception handling to the rest framework Mostly a conversion of treeherders ORM exceptions to drf APIExceptions """ import traceback full_message = traceback.format_exc() logger.error(exc) logger.error(full_message) if isinstance(exc, DatasetNotFoundError): exc = ResourceNotFoundException("No project with name {0}".format( exc.project)) if isinstance(exc, ObjectNotFoundException): exc = ResourceNotFoundException( "{0} object not found using: {1}".format(exc.table, unicode(exc.extra_info))) return drf_exc_handler(exc, context)
def exception_handler(exc, context): """ Add treeherder-specific exception handling to the rest framework Mostly a conversion of treeherders ORM exceptions to drf APIExceptions """ import traceback full_message = traceback.format_exc() logger.error(exc) logger.error(full_message) if isinstance(exc, DatasetNotFoundError): exc = ResourceNotFoundException( "No project with name {0}".format(exc.project) ) if isinstance(exc, ObjectNotFoundException): exc = ResourceNotFoundException( "{0} object not found using: {1}".format( exc.table, unicode(exc.extra_info))) return drf_exc_handler(exc, context)