handleError({ segment, transaction, span }) {
    if (span?.status?.code === SPAN_STATUS_CODE.ERROR) {
      const errorEvents = span.events.filter((event) => event.name === 'exception')
      for (const err of errorEvents) {
        const msg = exceptionAttr({ key: 'msg', span: err }) ?? `Error from ${segment.name}`
        const stack = exceptionAttr({ key: 'stack', span: err })
        const error = new Error(msg)
        error.stack = stack
        this.agent.errors.add(transaction, error, null, segment)
      }
    }
  }
Adds an error to the transaction if the span has a status code of ERROR
and the span has an exception event. The error is created from the exception
event attributes and added to the transaction.
@param {object} params - The parameters for the error handling.
@param {object} params.segment - The segment to add the error to.
@param {object} params.transaction - The transaction to add the error to.
@param {object} params.span - The span to check for errors.