예제 #1
0
func TestMultiStackSingleStack(t *testing.T) {
	frame := stack.Frame{Name: "42"}
	s := stack.Stack{frame}
	var multi stack.Multi
	multi.Add(s)
	ensure.DeepEqual(t, MultiStack(&singleStackError{stack: s}), &multi)
}
예제 #2
0
func TestStackMultiStack(t *testing.T) {
	frame := stack.Frame{Name: "42"}
	s := stack.Stack{frame}
	var multi stack.Multi
	multi.Add(s)
	ensure.DeepEqual(t, Stack(&multiStackError{multiStack: &multi}), s)
}
예제 #3
0
파일: ctxerr.go 프로젝트: chrisp-fb/rell
// MultiStack returns the best possible stack.Multi from the error or nil if
// one isn't found.
func MultiStack(err error) *stack.Multi {
	switch err := err.(type) {
	case *singleFrameError:
		var m stack.Multi
		m.Add(stack.Stack{err.frame})
		return &m
	case *singleStackError:
		var m stack.Multi
		m.Add(err.stack)
		return &m
	case *multiStackError:
		return err.multiStack
	}
	return nil
}
예제 #4
0
func TestMultiStackStringModeNone(t *testing.T) {
	err := errors.New("foo")
	var m stack.Multi
	m.Add(stack.Stack{
		stack.Frame{
			File: "f",
			Line: 1,
			Name: "n",
		},
	})
	ensure.DeepEqual(
		t,
		(&multiStackError{
			underlying: err,
			config:     Config{},
			multiStack: &m,
		}).Error(),
		`foo`)
}
예제 #5
0
func TestMultiStackSingleFrame(t *testing.T) {
	frame := stack.Frame{Name: "42"}
	var multi stack.Multi
	multi.Add(stack.Stack{frame})
	ensure.DeepEqual(t, MultiStack(&singleFrameError{frame: frame}), &multi)
}