1212 DAObject ,
1313 DADateTime ,
1414 as_datetime ,
15+ current_context ,
1516 validation_error ,
1617 log ,
1718 as_datetime ,
4950TypeType = type (type (None ))
5051
5152
52- def error_notification (err , message = None , trace = None , referer = None , the_vars = None ):
53+ def error_notification (err , message = None , trace = None , referer = None ):
5354 """Copied from docassemble.webapp.server.error_notification, since:
5455 1) things from webapp.* are unstable
5556 2) it breaks the unit tests and the mypy
@@ -79,31 +80,6 @@ def error_notification(err, message=None, trace=None, referer=None, the_vars=Non
7980 email_address = user_info ().email
8081 except :
8182 email_address = None
82- referer = None
83- if get_config ("error notification variables" , get_config ("debug" , True )):
84- if the_vars is None :
85- try :
86- the_vars = docassemble .base .functions .all_variables (
87- include_internal = True
88- )
89- except :
90- pass
91- else :
92- the_vars = None
93- json_filename = None
94- if the_vars is not None and len (the_vars ):
95- try :
96- with tempfile .NamedTemporaryFile (
97- mode = "w" ,
98- prefix = "datemp" ,
99- suffix = ".json" ,
100- delete = False ,
101- encoding = "utf-8" ,
102- ) as fp :
103- fp .write (json .dumps (the_vars , sort_keys = True , indent = 2 ))
104- json_filename = fp .name
105- except :
106- pass
10783 interview_path = docassemble .base .functions .interview_path ()
10884 try :
10985 try :
@@ -152,29 +128,28 @@ def error_notification(err, message=None, trace=None, referer=None, the_vars=Non
152128 html += "\n </body>\n </html>"
153129 log (f"Trying to send error message { body } " )
154130 send_email (
155- subject = appname + " error: " + err .__class__ .__name ,
131+ subject = appname + " error: " + err .__class__ .__name__ ,
156132 to = email_recipients ,
157133 body = body ,
158134 html = html ,
159- attachments = [json_filename ],
160135 )
161136 except Exception as zerr :
162- log (str ( zerr ) )
137+ log (f"Failed to send original message: { zerr } " )
163138 body = "There was an error in the " + appname + " application."
164139 html = (
165140 "<html>\n <body>\n <p>There was an error in the "
166141 + appname
167142 + " application.</p>\n </body>\n </html>"
168143 )
169- log (f"Trying to send error message { body } " )
144+ log (f"Trying to send (lesser) error message { body } " )
170145 send_email (
171146 subject = appname + " error: " + err .__class__ .__name__ ,
172147 to = email_recipients ,
173148 body = body ,
174149 html = html ,
175- attachments = [json_filename ],
176150 )
177- except :
151+ except Exception as all_err :
152+ log (f"Big ol err: { all_err } " )
178153 pass
179154
180155
@@ -183,7 +158,7 @@ def log_error_and_notify(context: str, resp: Optional[ApiResponse] = None):
183158 the `error_notification_email` in the config."""
184159 message = f"context: { context } ;; resp: { resp } "
185160 log (f"EFSPIntegration ERROR: { message } " )
186- error_notification (resp , message = message )
161+ error_notification (resp , message = message , referer = current_context (). filename )
187162
188163
189164def convert_court_to_id (trial_court ) -> str :
0 commit comments