17 lines
482 B
Python
17 lines
482 B
Python
from app.db.schemas import ErrorCreate
|
|
from app.db.session import SessionLocal
|
|
from app.db.crud import create_log
|
|
|
|
class APIException(Exception):
|
|
|
|
def __init__(self,location:str,title:str,content:str):
|
|
if(len(content) > 5000):
|
|
content =content[0:5000]
|
|
self.error = ErrorCreate(location=location,title=title,content=content)
|
|
|
|
def writedblog(exc: APIException):
|
|
db = SessionLocal()
|
|
try:
|
|
create_log(db,exc.error)
|
|
finally:
|
|
db.close() |