errors: handling, locale
This commit is contained in:
@@ -61,7 +61,9 @@ export default {
|
||||
'Verdammt, Fehler auf unserer Seite, probieren Sie es nochmal, danach rufen Sie jemanden vom Verein an.',
|
||||
not_possible: 'Vorgang nicht möglich.',
|
||||
not_found: 'Konnte nicht gefunden werden.',
|
||||
in_use: 'Ist in Benutzung'
|
||||
in_use: 'Ist in Benutzung',
|
||||
undelivered_verification_mail:
|
||||
'Registrierung erfolgreicht, leider konnte die Verifizierungs-E-Mail nicht versendet werden. Bitte wenden Sie sich an den Verein um Ihre Emailadresse zu bestätigen und Ihren Account zu aktivieren.'
|
||||
},
|
||||
validation: {
|
||||
invalid_user_id: 'Nutzer ID ungültig',
|
||||
|
||||
@@ -92,3 +92,17 @@ func HandleVerifyUserError(c *gin.Context, err error) {
|
||||
RespondWithError(c, err, "Couldn't verify user", http.StatusInternalServerError, errors.Responses.Fields.General, errors.Responses.Keys.InternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
func HandleDeleteUserError(c *gin.Context, err error) {
|
||||
if err.Error() == "record not found" {
|
||||
RespondWithError(c, err, "Couldn't find user", http.StatusNotFound, errors.Responses.Fields.User, errors.Responses.Keys.NotFound)
|
||||
}
|
||||
switch err {
|
||||
case errors.ErrUserNotFound:
|
||||
RespondWithError(c, err, "User not found", http.StatusNotFound, errors.Responses.Fields.User, errors.Responses.Keys.NotFound)
|
||||
case errors.ErrNoData:
|
||||
RespondWithError(c, err, "No data transmitted", http.StatusNotFound, errors.Responses.Fields.User, errors.Responses.Keys.Invalid)
|
||||
default:
|
||||
RespondWithError(c, err, "Couldn't delete user", http.StatusInternalServerError, errors.Responses.Fields.User, errors.Responses.Keys.InternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ type ValidationKeys struct {
|
||||
NoAuthToken string
|
||||
NotFound string
|
||||
InUse string
|
||||
UndeliveredVerificationMail string
|
||||
}
|
||||
|
||||
type ValidationFields struct {
|
||||
@@ -70,6 +71,7 @@ var Responses = struct {
|
||||
NoAuthToken: "server.error.no_auth_token",
|
||||
NotFound: "server.error.not_found",
|
||||
InUse: "server.error.in_use",
|
||||
UndeliveredVerificationMail: "server.error.undelivered_verification_mail",
|
||||
},
|
||||
Fields: ValidationFields{
|
||||
General: "general",
|
||||
|
||||
Reference in New Issue
Block a user