MCPcopy
hub / github.com/dropbox/godropbox / TestCustomError

Function TestCustomError

errors/errors_test.go:261–280  ·  view source on GitHub ↗

---------------------------------------

(t *testing.T)

Source from the content-addressed store, hash-verified

259// ---------------------------------------
260
261func TestCustomError(t *testing.T) {
262 dbMsg := "database error 1205 (lock wait time exceeded)"
263 outerMsg := "outer msg"
264
265 dbError := newDatabaseError(dbMsg, 1205)
266 outerError := Wrap(dbError, outerMsg)
267
268 errorStr := outerError.Error()
269 if strings.Index(errorStr, dbMsg) == -1 {
270 t.Errorf("couldn't find database error message in:\n%s", errorStr)
271 }
272
273 if strings.Index(errorStr, outerMsg) == -1 {
274 t.Errorf("couldn't find outer error message in:\n%s", errorStr)
275 }
276
277 if strings.Index(errorStr, "errors.TestCustomError") == -1 {
278 t.Errorf("couldn't find this function in stack trace:\n%s", errorStr)
279 }
280}
281
282type customErr struct {
283}

Callers

nothing calls this directly

Calls 3

newDatabaseErrorFunction · 0.85
WrapFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected