from flask import current_app, jsonify

errors = {
    "InternalServerError": {
        "message": "Something went wrong",
        "status": 500
    },
    "SchemaValidationError": {
        "message": "Request is missing required fields",
        "status": 400
    },
    "EmailAlreadyExistsError": {
        "message": "User with given email address already exists",
        "status": 400
    },
    "UnauthorizedError": {
        "message": "Invalid username or password",
        "status": 401
    },
    "EmailDoesnotExistsError": {
        "message": "Couldn't find the user with given email address",
        "status": 400
    },
    "ExpiredTokenError": {
        "message": "Expired token",
        "status": 403
    },
    "BadTokenError": {
        "message": "Invalid token",
        "status": 403
    }
}


def error_handle(e):
    print(current_app.config['DEBUG'])
    if(current_app.config['DEBUG']):
        raise e
    else:
        print(current_app.config['DEBUG'])
        raise e
        return jsonify(errors["InternalServerError"])
