예제 #1
0
파일: ensure.go 프로젝트: chrisp-fb/rell
func (c cond) String() string {
	var b bytes.Buffer
	if c.DisableDeleteSelf {
		fmt.Fprint(&b, "\n")
	} else {
		fmt.Fprint(&b, deleteSelf)
	}
	fmt.Fprint(&b, pstack(stack.Callers(c.Skip+1), c.DisableDeleteSelf))
	if c.Format != "" {
		fmt.Fprintf(&b, c.Format, c.FormatArgs...)
	}
	if len(c.Extra) != 0 {
		fmt.Fprint(&b, "\n")
		fmt.Fprint(&b, tsdump(c.Extra...))
	}
	return b.String()
}
예제 #2
0
파일: ctxerr.go 프로젝트: chrisp-fb/rell
// WrapSkip may wrap the error and return an augmented error depending on the
// configuration in the context. The defaults result in the error being
// returned as is. It also handles nils correctly, returning a nil in that
// case. If the given error is already wrapped, it returns it as-is.
func WrapSkip(ctx context.Context, err error, skip int) error {
	switch err := err.(type) {
	case nil:
		return nil
	case *singleFrameError:
		return err
	case *singleStackError:
		return err
	case *multiStackError:
		err.multiStack.AddCallers(skip + 1)
		return err
	}

	config := ContextConfig(ctx)
	switch config.StackMode {
	case StackModeSingleFrame:
		return &singleFrameError{
			config:     config,
			underlying: err,
			frame:      stack.Caller(skip + 1),
		}
	case StackModeSingleStack:
		return &singleStackError{
			config:     config,
			underlying: err,
			stack:      stack.Callers(skip + 1),
		}
	case StackModeMultiStack:
		return &multiStackError{
			config:     config,
			underlying: err,
			multiStack: stack.CallersMulti(skip + 1),
		}
	}
	return err
}
예제 #3
0
func BenchmarkCallers(b *testing.B) {
	for i := 0; i < b.N; i++ {
		stack.Callers(0)
	}
}
예제 #4
0
func (m typ) indirect1() stack.Stack {
	return stack.Callers(0)
}