-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #352 from DNO-inc/improve_auth_logs
Improve auth logs
- Loading branch information
Showing
10 changed files
with
100 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from fastapi.responses import JSONResponse | ||
from fastapi.exceptions import HTTPException | ||
|
||
from burrito.utils.logger import get_logger | ||
|
||
|
||
class DBConnectionError(HTTPException): | ||
def __init__(self, detail: str = "One of dbs is unreachable") -> None: | ||
super().__init__(500, detail) | ||
|
||
def __str__(self) -> str: | ||
return super().__repr__() | ||
|
||
|
||
class MySQLConnectionError(DBConnectionError): | ||
def __init__(self, detail: str = "Can't connect to MySQL") -> None: | ||
super().__init__(detail) | ||
|
||
|
||
class RedisConnectionError(DBConnectionError): | ||
def __init__(self, detail: str = "Can't connect to Redis") -> None: | ||
super().__init__(detail) | ||
|
||
|
||
class MongoConnectionError(DBConnectionError): | ||
def __init__(self, detail: str = "Can't connect to Mongo") -> None: | ||
super().__init__(detail) | ||
|
||
|
||
def db_connection_error_handler(request, exc) -> JSONResponse: | ||
get_logger().critical(str(exc)) | ||
return JSONResponse( | ||
content={"detail": "Some internal services is unreachable"}, | ||
status_code=500 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters