Skip to content

Commit 3489df0

Browse files
authored
feat: custome error messages (#14)
* feat: custome error messages * errors: improve code * errors: clean up imports * errors: add translations * errors: check if translation exists
1 parent d5ca315 commit 3489df0

20 files changed

Lines changed: 148 additions & 22 deletions

errors/errors.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,26 @@ var (
1919
ErrSourceIsParent = errors.New("source is parent")
2020
ErrRootUserDeletion = errors.New("user with id 1 can't be deleted")
2121
)
22+
23+
type HTTPError struct {
24+
Err error
25+
Type string
26+
}
27+
28+
func (e *HTTPError) Error() string {
29+
if e.Err == nil {
30+
return e.Type
31+
}
32+
return e.Err.Error()
33+
}
34+
35+
func (e *HTTPError) Unwrap() error {
36+
return e.Err
37+
}
38+
39+
func NewHTTPError(err error, errType string) error {
40+
return &HTTPError{
41+
Err: err,
42+
Type: errType,
43+
}
44+
}

frontend/src/components/prompts/Archive.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ export default {
7676
7777
try {
7878
buttons.loading("archive");
79-
this.$store.commit("closeHovers");
8079
await api.archive(uri, this.name, format, ...items);
80+
this.$store.commit("closeHovers");
8181
this.$store.commit("setReload", true);
82+
this.$store.dispatch("quota/fetch", 3000);
8283
} catch (e) {
8384
this.$showError(e);
8485
} finally {
8586
buttons.done("archive");
8687
}
87-
this.$store.dispatch("quota/fetch", 3000);
8888
},
8989
},
9090
};

frontend/src/i18n/ar_AR.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@
4848
"connection": "The server can't be reached.",
4949
"forbidden": "You don't have permissions to access this.",
5050
"internal": "لقد حدث خطأ ما.",
51-
"notFound": "لا يمكن الوصول لهذا المحتوى."
51+
"notFound": "لا يمكن الوصول لهذا المحتوى.",
52+
"resource": {
53+
"alreadyExists": "Resource with such name already exists"
54+
},
55+
"validation": {
56+
"emptyName": "Resource name can't be empty"
57+
}
5258
},
5359
"files": {
5460
"body": "الصفحة",

frontend/src/i18n/en_GB.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@
4848
"connection": "The server can't be reached.",
4949
"forbidden": "You don't have permissions to access this.",
5050
"internal": "Something really went wrong.",
51-
"notFound": "This location can't be reached."
51+
"notFound": "This location can't be reached.",
52+
"resource": {
53+
"alreadyExists": "Resource with such name already exists"
54+
},
55+
"validation": {
56+
"emptyName": "Resource name can't be empty"
57+
}
5258
},
5359
"files": {
5460
"body": "Body",

frontend/src/i18n/es_AR.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@
4848
"connection": "The server can't be reached.",
4949
"forbidden": "No tienes los permisos necesarios para acceder.",
5050
"internal": "La verdad es que algo ha ido mal.",
51-
"notFound": "No se puede acceder a este lugar."
51+
"notFound": "No se puede acceder a este lugar.",
52+
"resource": {
53+
"alreadyExists": "Resource with such name already exists"
54+
},
55+
"validation": {
56+
"emptyName": "Resource name can't be empty"
57+
}
5258
},
5359
"files": {
5460
"body": "Cuerpo",

frontend/src/i18n/es_CO.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@
4848
"connection": "The server can't be reached.",
4949
"forbidden": "No tienes los permisos necesarios para acceder.",
5050
"internal": "La verdad es que algo ha ido mal.",
51-
"notFound": "No se puede acceder a este lugar."
51+
"notFound": "No se puede acceder a este lugar.",
52+
"resource": {
53+
"alreadyExists": "Resource with such name already exists"
54+
},
55+
"validation": {
56+
"emptyName": "Resource name can't be empty"
57+
}
5258
},
5359
"files": {
5460
"body": "Cuerpo",

frontend/src/i18n/es_ES.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@
4848
"connection": "The server can't be reached.",
4949
"forbidden": "No tienes los permisos necesarios para acceder.",
5050
"internal": "La verdad es que algo ha ido mal.",
51-
"notFound": "No se puede acceder a este lugar."
51+
"notFound": "No se puede acceder a este lugar.",
52+
"resource": {
53+
"alreadyExists": "Resource with such name already exists"
54+
},
55+
"validation": {
56+
"emptyName": "Resource name can't be empty"
57+
}
5258
},
5359
"files": {
5460
"body": "Cuerpo",

frontend/src/i18n/es_MX.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@
4848
"connection": "The server can't be reached.",
4949
"forbidden": "No tienes los permisos necesarios para acceder.",
5050
"internal": "La verdad es que algo ha ido mal.",
51-
"notFound": "No se puede acceder a este lugar."
51+
"notFound": "No se puede acceder a este lugar.",
52+
"resource": {
53+
"alreadyExists": "Resource with such name already exists"
54+
},
55+
"validation": {
56+
"emptyName": "Resource name can't be empty"
57+
}
5258
},
5359
"files": {
5460
"body": "Cuerpo",

frontend/src/i18n/fr_FR.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@
4848
"connection": "The server can't be reached.",
4949
"forbidden": "You don't have permissions to access this.",
5050
"internal": "Aïe ! Quelque chose s'est mal passé.",
51-
"notFound": "Impossible d'accéder à cet emplacement."
51+
"notFound": "Impossible d'accéder à cet emplacement.",
52+
"resource": {
53+
"alreadyExists": "Resource with such name already exists"
54+
},
55+
"validation": {
56+
"emptyName": "Resource name can't be empty"
57+
}
5258
},
5359
"files": {
5460
"body": "Corps",

frontend/src/i18n/id_ID.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@
4848
"connection": "The server can't be reached.",
4949
"forbidden": "You don't have permissions to access this.",
5050
"internal": "Something really went wrong.",
51-
"notFound": "This location can't be reached."
51+
"notFound": "This location can't be reached.",
52+
"resource": {
53+
"alreadyExists": "Resource with such name already exists"
54+
},
55+
"validation": {
56+
"emptyName": "Resource name can't be empty"
57+
}
5258
},
5359
"files": {
5460
"body": "Body",

0 commit comments

Comments
 (0)