Skip to content

Commit

Permalink
HAI-1841 Add better error messages for failed attachment uploads (#361)
Browse files Browse the repository at this point in the history
Added specific error messages for failed attachment uploads in
cable report application form. One for bad request (when there is
something wrong with the file) and one for error caused by technical reason.
  • Loading branch information
markohaarni authored Aug 24, 2023
1 parent cb82fba commit 4821d58
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/domain/johtoselvitys/JohtoselvitysContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,13 @@ const JohtoselvitysContainer: React.FC<React.PropsWithChildren<Props>> = ({
},
onError(error: AxiosError, { file }) {
setAttachmentUploadErrors((errors) => {
// TODO: Should show different error texts for different kinds of errors,
// once those texts have been defined
const errorMessage =
error.response?.status === 400
? t('form:errors:fileLoadBadFileError', { fileName: file.name })
: t('form:errors:fileLoadTechnicalError', { fileName: file.name });
return errors.concat(
<Box as="p" key={file.name} mb="var(--spacing-s)">
{file.name}: {t('common:error')}
{errorMessage}
</Box>,
);
});
Expand Down
4 changes: 3 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@
"errors": {
"areaRequired": "At least one area is required",
"fileLoadError": "Error in loading file",
"selfIntersectingArea": "The area borders cannot intersect with each other"
"selfIntersectingArea": "The area borders cannot intersect with each other",
"fileLoadTechnicalError": "Uploading the file ({{fileName}}) failed. Please try again later.",
"fileLoadBadFileError": "There is a problem with the file ({{fileName}}). Please check that the file format is correct and the file size does not exceed 100 MB."
},
"headers": {
"perustiedot": "Basic information",
Expand Down
4 changes: 3 additions & 1 deletion src/locales/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@
"errors": {
"areaRequired": "Vähintään yksi alue vaaditaan",
"fileLoadError": "Tiedoston latauksessa tapahtui virhe",
"selfIntersectingArea": "Alueen reunat eivät saa leikata toisiaan"
"selfIntersectingArea": "Alueen reunat eivät saa leikata toisiaan",
"fileLoadTechnicalError": "Tiedoston ({{fileName}}) lataus epäonnistui, yritä hetken päästä uudelleen.",
"fileLoadBadFileError": "Tiedosto ({{fileName}}) on viallinen. Tarkistathan, että tiedostomuoto on oikea eikä sen koko ylitä sallittua maksimikokoa."
},
"headers": {
"perustiedot": "Perustiedot",
Expand Down
4 changes: 3 additions & 1 deletion src/locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@
"errors": {
"areaRequired": "Det krävs minst ett område",
"fileLoadError": "Fel i laddning av fil",
"selfIntersectingArea": "Områdets kanter får inte skära varandra"
"selfIntersectingArea": "Områdets kanter får inte skära varandra",
"fileLoadTechnicalError": "Laddning av filen ({{fileName}}) misslyckades, försök igen om en stund.",
"fileLoadBadFileError": "Filen ({{fileName}}) är felaktig. Kontrollera att filen har rätt format och att den inte är större än 100 MB."
},
"headers": {
"perustiedot": "Basdata",
Expand Down

0 comments on commit 4821d58

Please sign in to comment.