Skip to content

Commit

Permalink
language error output
Browse files Browse the repository at this point in the history
  • Loading branch information
z0rr0 committed Jul 31, 2023
1 parent d8adbfb commit cfd8ddf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion handle/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (y *Handler) setLanguages(ctx context.Context, direction string) error {
}

if !languages.Contains(fromLanguage, toLanguage) {
return fmt.Errorf("unknown language direction: %s -> %s", fromLanguage, toLanguage)
return fmt.Errorf("unknown language direction: %s -> %s\n%v", fromLanguage, toLanguage, languages.String())
}

y.fromLanguage, y.toLanguage = fromLanguage, toLanguage
Expand Down
5 changes: 3 additions & 2 deletions handle/handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,14 @@ func TestHandler_Run(t *testing.T) {
name: "dictionary_err",
direction: "de-fr",
params: []string{"time"},
error: "unknown language direction: de -> fr",
error: "unknown language direction: de -> fr\nDictionary languages:\nen-en, en-ru",
},
{
name: "translation_err",
direction: "de-fr",
params: []string{"time to start"},
error: "unknown language direction: de -> fr",
error: "unknown language direction: de -> fr\nTranslation languages:\nru, en\n" +
"ru - Russian en - English ",
},
}

Expand Down

0 comments on commit cfd8ddf

Please sign in to comment.