class Sentry::SingleExceptionInterface

def self.build_with_stacktrace(exception:, stacktrace_builder:)

also see `StacktraceBuilder.build`.
patch this method if you want to change an exception's stacktrace frames
def self.build_with_stacktrace(exception:, stacktrace_builder:)
  stacktrace = stacktrace_builder.build(backtrace: exception.backtrace)
  if locals = exception.instance_variable_get(:@sentry_locals)
    locals.each do |k, v|
      locals[k] =
        begin
          v = v.inspect unless v.is_a?(String)
          if v.length >= MAX_LOCAL_BYTES
            v = v.byteslice(0..MAX_LOCAL_BYTES - 1) + OMISSION_MARK
          end
          v
        rescue StandardError
          PROBLEMATIC_LOCAL_VALUE_REPLACEMENT
        end
    end
    stacktrace.frames.last.vars = locals
  end
  new(exception: exception, stacktrace: stacktrace)
end