def METHOD_NAME(stdout, stderr, param):
    def create_error_result(error_msg):
        return TracerouteResult(
            error=error_msg,
            host_or_ip=param.host_or_ip,
            stats=None,
        )
    if stderr:
        return create_error_result(stderr)
    else:
        try:
            stats = TracerouteParser().parse(stdout)
            return TracerouteResult(
                error=None,
                host_or_ip=param.host_or_ip,
                stats=stats,
            )
        except ValueError as e:
            msg = 'Error while parsing output. ' \
                  'Original exception message:\n{}'.format(str(e.args[0]))
            return create_error_result(msg)
        except IndexError as e:
            msg = 'Error while parsing output - an incomplete line ' \
                  'was encountered. Original exception message:\n{}' \
                .format(str(e.args[0]))
            return create_error_result(msg)