function createError(transaction, exception, config) {
  const error = exception.error
  const { name, message, type } = errorHelper.extractErrorInformation(
    transaction,
    error,
    config,
    urltils
  )

  const params = {
    userAttributes: Object.create(null),
    agentAttributes: Object.create(null),
    intrinsics: Object.create(null)
  }

  if (transaction) {
    // Copy all of the parameters off of the transaction.
    params.intrinsics = transaction.getIntrinsicAttributes()
    const transactionAgentAttributes =
      transaction.trace.attributes.get(DESTINATIONS.ERROR_EVENT) || {}

    // Merge the agent attributes specific to this error event with the transaction attributes
    params.agentAttributes = Object.assign(exception.agentAttributes, transactionAgentAttributes)

    // There should be no attributes to copy in HSM, but check status anyway
    if (!config.high_security) {
      urltils.overwriteParameters(
        transaction.trace.custom.get(DESTINATIONS.ERROR_EVENT),
        params.userAttributes
      )
    }
  }

  maybeAddUserAttributes(params.userAttributes, exception, config)

  params.stack_trace = maybeAddStackTrace(exception, config)

  params.intrinsics[ERROR_EXPECTED_PATH] =
    exception._expected || errorHelper.isExpected(type, message, transaction, config, urltils)

  maybeAddAgentAttributes(params, exception)

  return [0, name, message, type, params, transaction?.id]
}
Given either or both of a transaction and an exception, generate an error
trace in the JSON format expected by the collector. Since this will be
used by both the HTTP instrumentation, which uses HTTP status codes to
determine whether a transaction is in error, and the domain-based error
handler, which traps actual instances of Error, try to set sensible
defaults for everything.

NOTE: this function returns an array, but also conditionally mutates the array
to add a "transaction" property with the transaction id to the array, which works
because everything's an object in JS. I'm not entirely sure why we do this, but
weird enough to make note of

@param {Transaction} transaction  The agent transaction, coming from the instrumentatation
@param {Exception}   exception    An custom Exception object with the error and other information
@param {object}      config       The configuration to use when creating the object
@returns {Array} an Array of Error information, [0] -> placeholder,
                                                [1] -> name extracted from error info,
                                                [2] -> extracted error message,
                                                [3] -> extracted error type,
                                                [4] -> attributes,
                                                [5] -> transaction id