summaryrefslogtreecommitdiffstats
path: root/openbb_platform/core/openbb_core/api/rest_api.py
diff options
context:
space:
mode:
Diffstat (limited to 'openbb_platform/core/openbb_core/api/rest_api.py')
-rw-r--r--openbb_platform/core/openbb_core/api/rest_api.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/openbb_platform/core/openbb_core/api/rest_api.py b/openbb_platform/core/openbb_core/api/rest_api.py
index 7c9e0f1488e..0ad92f613b6 100644
--- a/openbb_platform/core/openbb_core/api/rest_api.py
+++ b/openbb_platform/core/openbb_core/api/rest_api.py
@@ -67,13 +67,13 @@ app = FastAPI(
],
lifespan=lifespan,
)
-
app.add_middleware(
CORSMiddleware,
allow_origins=system.api_settings.cors.allow_origins,
allow_methods=system.api_settings.cors.allow_methods,
allow_headers=system.api_settings.cors.allow_headers,
)
+app.openapi_tags = AppLoader.get_openapi_tags()
AppLoader.from_routers(
app=app,
routers=(
@@ -88,6 +88,8 @@ AppLoader.from_routers(
@app.exception_handler(Exception)
async def api_exception_handler(_: Request, exc: Exception):
"""Exception handler for all other exceptions."""
+ if Env().DEBUG_MODE:
+ raise exc
logger.error(exc)
return JSONResponse(
status_code=404,
@@ -101,6 +103,8 @@ async def api_exception_handler(_: Request, exc: Exception):
@app.exception_handler(OpenBBError)
async def openbb_exception_handler(_: Request, exc: OpenBBError):
"""Exception handler for OpenBB errors."""
+ if Env().DEBUG_MODE:
+ raise exc
logger.error(exc.original)
openbb_error = exc.original
status_code = 400 if "No results" in str(openbb_error) else 500