MCPcopy Create free account
hub / github.com/juju/errors / TestNewErrWithCause

Method TestNewErrWithCause

error_test.go:156–168  ·  view source on GitHub ↗
(c *gc.C)

Source from the content-addressed store, hash-verified

154}
155
156func (*errorsSuite) TestNewErrWithCause(c *gc.C) {
157 if runtime.Compiler == "gccgo" {
158 c.Skip("gccgo can't determine the location")
159 }
160 causeErr := fmt.Errorf("external error")
161 err := errors.NewErrWithCause(causeErr, "testing %d", 43)
162 err.SetLocation(0)
163 locLine := errorLocationValue(c)
164
165 c.Assert(err.Error(), gc.Equals, "testing 43: external error")
166 c.Assert(errors.Cause(&err), gc.Equals, causeErr)
167 c.Assert(errors.Details(&err), Contains, locLine)
168}
169
170func (*errorsSuite) TestUnwrapNewErrGivesNil(c *gc.C) {
171 err := errors.New("test error")

Callers

nothing calls this directly

Calls 6

NewErrWithCauseFunction · 0.92
CauseFunction · 0.92
DetailsFunction · 0.92
errorLocationValueFunction · 0.85
SetLocationMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected