forked from BD-Python-PIP/code-examples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror_handlers.py
More file actions
32 lines (26 loc) · 1.12 KB
/
error_handlers.py
File metadata and controls
32 lines (26 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import json
from flask import render_template
from .api_type import EXAMPLES_API_TYPE
def process_error(err):
error_body_json = err and hasattr(err, "body") and err.body
# we can pull the DocuSign error code and message from the response body
try:
error_body = json.loads(error_body_json)
except json.decoder.JSONDecodeError:
error_body = {}
error_code = error_body and "errorCode" in error_body and error_body["errorCode"]
error_message = error_body and "message" in error_body and error_body["message"]
# Handle error specific for use conditional recipients example (eg34)
if error_code == "WORKFLOW_UPDATE_RECIPIENTROUTING_NOT_ALLOWED":
return render_template("eSignature/error_eg34.html")
if EXAMPLES_API_TYPE["Monitor"]:
if ("(403" in str(err)):
return render_template("error_enable_monitor.html")
# In production, may want to provide customized error messages and
# remediation advice to the user.
return render_template(
"error.html",
err=err,
error_code=error_code,
error_message=error_message
)