Не показывать клиенту контекст обёртки ошибок
This commit is contained in:
@@ -319,8 +319,10 @@ func TestUnavailableCauseIsLoggedButNotReturned(t *testing.T) {
|
||||
})
|
||||
rec, eb := do(t, e, http.MethodGet, "/down", "", nil)
|
||||
assertError(t, rec, eb, http.StatusServiceUnavailable, "unavailable")
|
||||
if strings.Contains(rec.Body.String(), "connection refused") {
|
||||
t.Fatalf("cause leaked to the client: %s", rec.Body.String())
|
||||
// Neither the cause nor the wrapping context of internal operations
|
||||
// ("select user: ...") may reach the client.
|
||||
if eb.Error.Message != "database unavailable" {
|
||||
t.Fatalf("client message = %q, want only the application message", eb.Error.Message)
|
||||
}
|
||||
if !strings.Contains(logs.String(), "connection refused") || !strings.Contains(logs.String(), eb.Error.RequestID) {
|
||||
t.Fatalf("log must carry the cause and the request id, got:\n%s", logs.String())
|
||||
|
||||
Reference in New Issue
Block a user