def METHOD_NAME(self, formatted, payload):
    # type: (StringIO, bytes) -> None
    loaded_error = json.loads(payload)
    error_message = loaded_error['errorMessage']
    error_type = loaded_error.get('errorType')
    stack_trace = loaded_error.get('stackTrace')
    if stack_trace is not None:
        self._format_stacktrace(formatted, stack_trace)
    if error_type is not None:
        formatted.write('{}: {}\n'.format(error_type, error_message))
    else:
        formatted.write('{}\n'.format(error_message))