X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=it%2Fotf.git;a=blobdiff_plain;f=a1-sdnc-vth%2Fapp%2Fhelpers%2Ferror_helper.py;fp=a1-sdnc-vth%2Fapp%2Fhelpers%2Ferror_helper.py;h=b34cedf58d0713774847c8d43d80101419b03a53;hp=0000000000000000000000000000000000000000;hb=63b197b11b12a536254352f134262ad90f31593b;hpb=fa00af93f9173da630cd425fa8e0cbfaadf39a68 diff --git a/a1-sdnc-vth/app/helpers/error_helper.py b/a1-sdnc-vth/app/helpers/error_helper.py new file mode 100644 index 0000000..b34cedf --- /dev/null +++ b/a1-sdnc-vth/app/helpers/error_helper.py @@ -0,0 +1,51 @@ +from flask import current_app +import datetime +""" +Args: +Returns: +Examples: +""" + +def error_dic(error, status_code, response_message="Something went wrong, vth encountered an error"): + """ + Args: + Returns: + Examples: + """ + message = [str(x) for x in error.args] + error_log={ + "error":{ + "type": error.__class__.__name__, + "message": message + } + } + response_data = { + "vthResponse": { + "testDurationMS": 0, + 'dateTimeUTC': str(datetime.datetime.now()), + "abstractMessage": "Failed", + "error":response_message, + "status_code": status_code, + "resultData": {} + } + } + current_app.logger.error(error_log) + return response_data + +def error_dic2(error, status_code=500): + """ + Args: + Returns: + Examples: + """ + message = [str(x) for x in error.args] + response = { + "status_code" : status_code, + "success": False, + "error":{ + "type": error.__class__.__name__, + "message": message + } + } + return response +