class ElasticAPM::Serializers::Errors

@api private

def build(error)

rubocop:disable Metrics/MethodLength
def build(error)
  base = {
    id: error.id,
    culprit: error.culprit,
    timestamp: micros_to_time(error.timestamp).utc.iso8601,
    context: error.context.to_h
  }
  if (exception = error.exception)
    base[:exception] = build_exception exception
  end
  if (transaction_id = error.transaction_id)
    base[:transaction] = { id: transaction_id }
  end
  base
end

def build_all(errors)

def build_all(errors)
  { errors: Array(errors).map(&method(:build)) }
end

def build_exception(exception)

def build_exception(exception)
  {
    message: exception.message,
    type: exception.type,
    module: exception.module,
    code: exception.code,
    attributes: exception.attributes,
    stacktrace: exception.stacktrace.to_a,
    handled: exception.handled
  }
end