// ErrorWithStackSkipWithExtras sends an error to Rollbar with the given
// severity level and a given number of stack trace frames skipped with
// extra custom data.
770668
func (c *Client) ErrorWithStackSkipWithExtras(level string, err error, skip int, extras map[string]interface{}) {
	c.ErrorWithStackSkipWithExtrasAndContext(context.TODO(), level, err, skip, extras)
}
544712
func (h *AsyncHttpHandler) CompletedWithError(err error) {

	h.manager.lock.RLock()
	defer h.manager.lock.RUnlock()

	godbc.Require(h.completed == false)

	h.err = err
	h.completed = true

	godbc.Ensure(h.completed == true)
}
342983
func (o *ListTasksOK) WithXLastTaskID(xLastTaskID int64) *ListTasksOK {
	o.XLastTaskID = xLastTaskID
	return o
}
470848
func (t *JSONFormatter) FormatSkip(errin error, skip int) (errtext string, err error) {
	errjson, err := newJSON(skip+1, errin)
	if errjson == nil || err != nil {
		return "", err
	}

	buffer := &bytes.Buffer{}
	if err = json.NewEncoder(buffer).Encode(errjson); err != nil {
		return
	}

	return buffer.String(), nil
}
746681
func rollbarError(logger ClientLogger, format string, args ...interface{}) {
	format = "Rollbar error: " + format + "\n"
	if logger != nil {
		logger.Printf(format, args...)
	} else {
		log.Printf(format, args...)
	}
}
1219193
func (h *LogReporter) ReportWithLevel(ctx context.Context, level string, err error) error {
	var file, line string
	var stack errors.StackTrace

	if errWithStack, ok := err.(stackTracer); ok {
		stack = errWithStack.StackTrace()
	}
	if stack != nil && len(stack) > 0 {
		file = fmt.Sprintf("%s", stack[0])
		line = fmt.Sprintf("%d", stack[0])
	} else {
		file = "unknown"
		line = "0"
	}

	if level == "debug" {
		logger.Debug(ctx, "", "debug", fmt.Sprintf(`"%v"`, err), "line", line, "file", file)
	} else if level == "info" {
		logger.Info(ctx, "", "info", fmt.Sprintf(`"%v"`, err), "line", line, "file", file)
	} else {
		logger.Error(ctx, "", level, fmt.Sprintf(`"%v"`, err), "line", line, "file", file)
	}
	return nil
}
539302
func ErrorWithStackSkip(level string, err error, skip int, fields ...*Field) {
	stack := BuildStack(2 + skip)
	ErrorWithStack(level, err, stack, fields...)
}
1343530
func PrintStackTrace() {
	buf := make([]byte, 1<<16)
	runtime.Stack(buf, true)
	fmt.Printf("%s", buf)
}
1144104
func (d *DefaultMetricCollector) Errors() *rolling.Number {
	d.mutex.RLock()
	defer d.mutex.RUnlock()
	return d.errors
}
554981
func NewWithStacks(format string, a ...interface{}) error {
	return &ErrorWithStacks{
		Err:    errors.New(errorPrintf(format, a...)),
		Stacks: stacks(2),
	}
}
371418
func WithMessagef(e error, format string, a ...interface{}) Error {
	if e == nil {
		return nil
	}
	return WrapSkipping(e, 1).WithMessagef(format, a...)
}
795961
func (c *Client) ErrorWithStackSkipWithExtrasAndContext(ctx context.Context, level string, err error, skip int, extras map[string]interface{}) {
	if !c.configuration.enabled {
		return
	}
	body := c.buildBody(ctx, level, err.Error(), extras)
	addErrorToBody(c.configuration, body, err, skip)
	c.push(body)
}
1021660
func CheckError(err error, level int) {
	if err != nil {
		var stack [4096]byte
		runtime.Stack(stack[:], false)
		log.Printf("%q\n%s\n", err, stack[:])

		switch level {
		case 0:
			glog.Infoln("%q\n%s\n", err)
		case 1:
			glog.Warningln("%q\n%s\n", err)
		case 2:
			glog.Errorln("%q\n%s\n", err)
		case 3:
			glog.Fatalln("%q\n%s\n", err)
		}

		glog.Flush()
	}
}
1049520
func backtraceFromErrorWithStackTrace(e stackTracer) (string, []StackFrame) {
	stackTrace := e.StackTrace()
	var pcs []uintptr
	for _, f := range stackTrace {
		pcs = append(pcs, uintptr(f))
	}

	ff := runtime.CallersFrames(pcs)
	var firstPkg string
	frames := make([]StackFrame, 0)
	for {
		f, ok := ff.Next()
		if !ok {
			break
		}

		pkg, fn := splitPackageFuncName(f.Function)
		if firstPkg == "" {
			firstPkg = pkg
		}

		frames = append(frames, StackFrame{
			File: f.File,
			Line: f.Line,
			Func: fn,
		})
	}

	return firstPkg, frames
}
738286
func (c *command) errorWithFallback(ctx context.Context, err error) {
	eventType := "failure"
	if err == ErrCircuitOpen {
		eventType = "short-circuit"
	} else if err == ErrMaxConcurrency {
		eventType = "rejected"
	} else if err == ErrTimeout {
		eventType = "timeout"
	} else if err == context.Canceled {
		eventType = "context_canceled"
	} else if err == context.DeadlineExceeded {
		eventType = "context_deadline_exceeded"
	}

	c.reportEvent(eventType)
	fallbackErr := c.tryFallback(ctx, err)
	if fallbackErr != nil {
		c.errChan <- fallbackErr
	}
}
468016
func ToLogrus(err error) logrus.Fields {
	result := logrus.Fields{
		"excValue": err.Error(),
		"excType":  fmt.Sprintf("%T", Cause(err)),
		"excText":  fmt.Sprintf("%+v", err),
	}

	// Add the stack info if provided
	if cast, ok := err.(stack.HasStackTrace); ok {
		trace := cast.StackTrace()
		caller := stack.GetLastFrame(trace)
		result["excFuncName"] = caller.Func
		result["excLineno"] = caller.LineNo
		result["excFileName"] = caller.File
	}

	// Add context if provided
	child, ok := err.(HasContext)
	if !ok {
		return result
	}

	// Append the context map to our results
	for key, value := range child.Context() {
		result[key] = value
	}
	return result
}
80681
func GetErrorStack(err error) []error {
	if annotated, ok := err.(*annotatedError); ok {
		result := []error{}
		for _, a := range annotated.stack {
			if a.err != nil {
				result = append(result, a.err)
			}
		}
		return result
	}
	return []error{err}
}