def handle_validation_error(e): print("\n type is " + str(e.__class__)) error_dict = e.messages errors = [] for key in error_dict: error_message = ','.join(error_dict[key]) errors.append(f"{key}: {error_message}") error_dto = ErrorResponse(errors, 'ValidationError') return create_response_object(error_dto, 400)
def post(self): id = self.__tenant_service__.create_tenant(request.json) return create_response_object(CreateResponseDto(id), 201)
def get(self): return create_response_object(HealthResponse('UP'), 200)
def post(self): user_id = self.__service__.register_user(request.json) return create_response_object(CreateResponseDto(user_id), 201)
def handle_internal_error(e): print(f"\n The error is {e} ") traceback.print_exc() error_dto = ErrorResponse([str(e)], 'InternalError') return create_response_object(error_dto, 500)
def handle_custom_auth_error(e): return create_response_object(ErrorResponse([e.get_message()], 'Auth'), 401)
def handle_custom_not_found_error(e): return create_response_object(ErrorResponse(e.get_message(), 'NotFound'), 404)
def handle_custom_validation_error(e): return create_response_object( ErrorResponse(e.get_message(), 'ValidationError'), 400)