Flask rollout prep: TypeError: Object of type ProgrammingError is not JSON serializable
The third most common error we get in Flask that we don't get in PHP is a problem serializing a ProgrammingError. What is supposed to happen here?

First occurrence: Apr 23, 10:35 AM

Last occurrence: Apr 26, 3:49 PM

```
builtins:TypeError: Object of type ProgrammingError is not JSON serializable
Traceback(most recent call last):
File "/usr/local/lib/python3.7/site-packages/newrelic/api/wsgi_application.py", line 47, in __iter__
File "/usr/local/lib/python3.7/site-packages/newrelic/api/wsgi_application.py", line 454, in __iter__
File "/usr/local/lib/python3.7/site-packages/werkzeug/wsgi.py", line 506, in __next__
File "/usr/local/lib/python3.7/site-packages/werkzeug/wrappers/base_response.py", line 45, in _iter_encoded
File "/usr/local/lib/python3.7/site-packages/flask/helpers.py", line 162, in generator
File "/app/app/_printer.py", line 57, in gen
File "/app/app/_printer.py", line 84, in _error
File "/usr/local/lib/python3.7/site-packages/flask/json/__init__.py", line 211, in dumps
File "/usr/local/lib/python3.7/json/__init__.py", line 238, in dumps
File "/usr/local/lib/python3.7/json/encoder.py", line 199, in encode
File "/usr/local/lib/python3.7/json/encoder.py", line 257, in iterencode
File "/usr/local/lib/python3.7/site-packages/flask/json/__init__.py", line 100, in default
File "/usr/local/lib/python3.7/json/encoder.py", line 179, in default
```
diff --git a/src/server/_printer.py b/src/server/_printer.py
index 68d27a8e..6f3cbc37 100644
--- a/src/server/_printer.py
+++ b/src/server/_printer.py
@@ -52,7 +52,7 @@ class APrinter:
                     if r is not None:
                         yield r
             except Exception as e:
-                app.logger.error(f"error executing")
+                app.logger.exception(f"error executing: {str(e)}")
                 self.result = -1
                 yield self._error(e)
 
@@ -81,7 +81,7 @@ class APrinter:
 
     def _error(self, error: Exception) -> str:
         # send an generic error
-        return dumps(dict(result=self.result, message=f"unknown error occurred: {error}", error=error, epidata=[]))
+        return dumps(dict(result=self.result, message=f"unknown error occurred: {error}", error=str(error), epidata=[]))
 
     def _print_row(self, row: Dict) -> Optional[Union[str, bytes]]:
         first = self.count == 0
diff --git a/src/server/endpoints/signal_dashboard_status.py b/src/server/endpoints/signal_dashboard_status.py
index fa4a54ed..72c06dc5 100644
--- a/src/server/endpoints/signal_dashboard_status.py
+++ b/src/server/endpoints/signal_dashboard_status.py
@@ -32,18 +32,18 @@ def handle():
 
     p = create_printer()
 
-    def gen(rows):
-        coverage_data = fetch_coverage_data()
+    def gen(rows, coverage_data):
         for row in rows:
             parsed = parse_row(row, fields_string, fields_int, fields_float)
             # inject coverage data
-            parsed['coverage'] = coverage_data.get(parsed['name'], {})
+            parsed["coverage"] = coverage_data.get(parsed["name"], {})
             yield parsed
 
     try:
+        coverage_data = fetch_coverage_data()
         r = run_query(p, (query, {}))
     except Exception as e:
         raise DatabaseErrorException(str(e))
 
     # now use a generator for sending the rows and execute all the other queries
-    return p(gen(r))
+    return p(gen(r, coverage_data))
['src/server/_printer.py', 'src/server/endpoints/signal_dashboard_status.py']