Clean untranslated logs (#21956)
Remove the word "<untranslated>" from appearing in the logs. ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6ad1861535
Коммит
356188de28
@@ -256,11 +256,15 @@ func (er *AppError) Error() string {
|
|||||||
// render the error information
|
// render the error information
|
||||||
sb.WriteString(er.Where)
|
sb.WriteString(er.Where)
|
||||||
sb.WriteString(": ")
|
sb.WriteString(": ")
|
||||||
sb.WriteString(er.Message)
|
if er.Message != NoTranslation {
|
||||||
|
sb.WriteString(er.Message)
|
||||||
|
}
|
||||||
|
|
||||||
// only render the detailed error when it's present
|
// only render the detailed error when it's present
|
||||||
if er.DetailedError != "" {
|
if er.DetailedError != "" {
|
||||||
sb.WriteString(", ")
|
if er.Message != NoTranslation {
|
||||||
|
sb.WriteString(", ")
|
||||||
|
}
|
||||||
sb.WriteString(er.DetailedError)
|
sb.WriteString(er.DetailedError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,11 @@ func TestAppError(t *testing.T) {
|
|||||||
t.Log(appErr.Error())
|
t.Log(appErr.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAppErrorNoTranslation(t *testing.T) {
|
||||||
|
appErr := NewAppError("TestAppError", NoTranslation, nil, "test error", http.StatusBadRequest)
|
||||||
|
require.Equal(t, "TestAppError: test error", appErr.Error())
|
||||||
|
}
|
||||||
|
|
||||||
func TestAppErrorJunk(t *testing.T) {
|
func TestAppErrorJunk(t *testing.T) {
|
||||||
rerr := AppErrorFromJSON(strings.NewReader("<html><body>This is a broken test</body></html>"))
|
rerr := AppErrorFromJSON(strings.NewReader("<html><body>This is a broken test</body></html>"))
|
||||||
require.Equal(t, "body: <html><body>This is a broken test</body></html>", rerr.DetailedError)
|
require.Equal(t, "body: <html><body>This is a broken test</body></html>", rerr.DetailedError)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user