nova-api/api/helpers/errors.py

21 lines
542 B
Python
Raw Permalink Normal View History

2023-08-01 20:19:18 +02:00
import json
import starlette
2023-08-06 21:42:07 +02:00
async def error(code: int, message: str, tip: str) -> starlette.responses.Response:
2023-08-01 20:19:18 +02:00
info = {'error': {
'code': code,
'message': message,
'tip': tip,
'website': 'https://nova-oss.com',
'by': 'NovaOSS/Nova-API'
}}
return starlette.responses.Response(status_code=code, content=json.dumps(info))
2023-08-06 21:42:07 +02:00
async def yield_error(code: int, message: str, tip: str) -> str:
return json.dumps({
'code': code,
'message': message,
'tip': tip
})