added new of dashboard and log apply on routes
This commit is contained in:
8
app/utils/exceptions.py
Normal file
8
app/utils/exceptions.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from app.constants.http_status import HTTPStatus
|
||||
|
||||
class APIException(Exception):
|
||||
def __init__(self, message, status_code=HTTPStatus.BAD_REQUEST, errors=None):
|
||||
self.message = message
|
||||
self.status_code = status_code
|
||||
self.errors = errors
|
||||
super().__init__(self.message)
|
||||
23
app/utils/response_handler.py
Normal file
23
app/utils/response_handler.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from flask import jsonify
|
||||
from app.constants.http_status import HTTPStatus
|
||||
|
||||
|
||||
class ResponseHandler:
|
||||
|
||||
@staticmethod
|
||||
def success(message, data=None, status_code=HTTPStatus.OK):
|
||||
return jsonify({
|
||||
"status": "success",
|
||||
"message": message,
|
||||
"data": data if data else {},
|
||||
"errors": []
|
||||
}), status_code
|
||||
|
||||
@staticmethod
|
||||
def error(message, errors=None, status_code=HTTPStatus.BAD_REQUEST):
|
||||
return jsonify({
|
||||
"status": "error",
|
||||
"message": message,
|
||||
"data": {},
|
||||
"errors": errors if errors else []
|
||||
}), status_code
|
||||
Reference in New Issue
Block a user