Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(translation): Use 400 as status code to be distinguishable from s…
…erver errors

Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Apr 13, 2023
commit 5a502c6973bc35fb72b20332ad3682c4c3b58180
4 changes: 2 additions & 2 deletions core/Controller/TranslationApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public function translate(string $text, ?string $fromLanguage, string $toLanguag
} catch (PreConditionNotMetException) {
return new DataResponse(['message' => $this->l->t('No translation provider available')], Http::STATUS_PRECONDITION_FAILED);
} catch (InvalidArgumentException) {
return new DataResponse(['message' => $this->l->t('Could not detect language')], Http::STATUS_NOT_FOUND);
return new DataResponse(['message' => $this->l->t('Could not detect language')], Http::STATUS_BAD_REQUEST);
} catch (RuntimeException) {
return new DataResponse(['message' => $this->l->t('Unable to translate')], Http::STATUS_INTERNAL_SERVER_ERROR);
return new DataResponse(['message' => $this->l->t('Unable to translate')], Http::STATUS_BAD_REQUEST);
}
}
}