From 21c636a27306428a4db0edbb787a86f500a45324 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Sat, 18 Apr 2020 23:19:12 -0700 Subject: [PATCH] cleanup --- hyperglass/api/__init__.py | 12 +++++++----- hyperglass/configuration/models/web.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hyperglass/api/__init__.py b/hyperglass/api/__init__.py index 2eb723c..65e145b 100644 --- a/hyperglass/api/__init__.py +++ b/hyperglass/api/__init__.py @@ -6,7 +6,7 @@ from pathlib import Path # Third Party from fastapi import FastAPI -from fastapi.exceptions import RequestValidationError +from fastapi.exceptions import ValidationError, RequestValidationError from starlette.responses import JSONResponse from starlette.exceptions import HTTPException as StarletteHTTPException from fastapi.openapi.utils import get_openapi @@ -23,8 +23,8 @@ from hyperglass.api.routes import ( query, queries, routers, - import_certificate, communities, + import_certificate, ) from hyperglass.exceptions import HyperglassError from hyperglass.configuration import URL_DEV, STATIC_PATH, params, devices @@ -98,9 +98,12 @@ app.add_exception_handler(StarletteHTTPException, http_handler) # Backend Application Error Handler app.add_exception_handler(HyperglassError, app_handler) -# Validation Error Handler +# Request Validation Error Handler app.add_exception_handler(RequestValidationError, validation_handler) +# App Validation Error Handler +app.add_exception_handler(ValidationError, validation_handler) + # Uncaught Error Handler app.add_exception_handler(Exception, default_handler) @@ -247,5 +250,4 @@ def start(**kwargs): """Start the web server with Uvicorn ASGI.""" import uvicorn - options = {**ASGI_PARAMS, **kwargs} - uvicorn.run("hyperglass.api:app", **options) + uvicorn.run("hyperglass.api:app", **ASGI_PARAMS, **kwargs) diff --git a/hyperglass/configuration/models/web.py b/hyperglass/configuration/models/web.py index 269886d..426f7b1 100644 --- a/hyperglass/configuration/models/web.py +++ b/hyperglass/configuration/models/web.py @@ -139,7 +139,7 @@ class Text(HyperglassModel): query_vrf: StrictStr = "Routing Table" fqdn_tooltip: StrictStr = "Use {protocol}" # Formatted by Javascript cache_prefix: StrictStr = "Results cached for " - cache_icon: StrictStr = "Cached Response from {time} UTC" # Formatted by Javascript + cache_icon: StrictStr = "Cached from {time} UTC" # Formatted by Javascript complete_time: StrictStr = "Completed in {seconds}" # Formatted by Javascript @validator("title_mode")