Handle an error generated in a routine decorated with the pyQuil error handler.

        :param exception: Exception object that generated this error.
        :param trace: inspect.trace object from the frame that caught the error.
        :return: ErrorReport object

def generate_report(self, exception, trace):
        """
        Handle an error generated in a routine decorated with the pyQuil error handler.

        :param exception: Exception object that generated this error.
        :param trace: inspect.trace object from the frame that caught the error.
        :return: ErrorReport object
        """
        stack_trace = [StacktraceFrame(name=item.function,
                                       filename=item.filename,
                                       line_number=item.lineno,
                                       locals={k: serialize_object_for_logging(v)
                                               for (k, v) in item.frame.f_locals.items()})
                       for item in trace]

        system_info = generate_system_info()

        report = ErrorReport(stack_trace=stack_trace,
                             timestamp=datetime.utcnow(),
                             exception=exception,
                             system_info=system_info,
                             call_log=flatten_log(self.log))

        return report