2019-12-02 10:48:46 +01:00
|
|
|
package errors
|
|
|
|
|
2019-12-07 11:44:19 +01:00
|
|
|
import (
|
|
|
|
"errors"
|
2019-12-02 10:48:46 +01:00
|
|
|
|
2019-12-07 11:44:19 +01:00
|
|
|
"git.andreafazzi.eu/andrea/oef/i18n"
|
|
|
|
)
|
|
|
|
|
2019-12-09 14:18:31 +01:00
|
|
|
type Error struct {
|
|
|
|
TemplateName string
|
|
|
|
Err error
|
2020-01-28 14:36:31 +01:00
|
|
|
Referer string
|
2020-02-19 11:19:47 +01:00
|
|
|
Title string
|
2019-12-09 14:18:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (e *Error) Error() string {
|
|
|
|
return e.Err.Error()
|
|
|
|
}
|
|
|
|
|
2019-12-07 11:44:19 +01:00
|
|
|
var (
|
2020-01-27 11:43:56 +01:00
|
|
|
RecordExists = errors.New("Record already exists!")
|
|
|
|
|
2020-02-05 10:10:27 +01:00
|
|
|
NotAuthorized = &Error{
|
2020-02-19 11:19:47 +01:00
|
|
|
Title: "Errore di autenticazione",
|
2020-02-05 10:10:27 +01:00
|
|
|
TemplateName: "error_not_authorized",
|
|
|
|
Err: errors.New(i18n.Authorization["notAuthorized"]["it"]),
|
|
|
|
}
|
2020-01-27 11:43:56 +01:00
|
|
|
|
|
|
|
SchoolExists = &Error{
|
2020-01-27 08:35:37 +01:00
|
|
|
TemplateName: "error_school_exists",
|
|
|
|
Err: errors.New(i18n.Errors["schoolExists"]["it"]),
|
|
|
|
}
|
2020-01-28 14:36:31 +01:00
|
|
|
|
2020-01-27 13:15:51 +01:00
|
|
|
ParticipantExists = &Error{
|
|
|
|
TemplateName: "error_participant_exists",
|
|
|
|
Err: errors.New(i18n.Errors["participantExists"]["it"]),
|
|
|
|
}
|
2020-01-27 08:35:37 +01:00
|
|
|
|
2019-12-09 14:18:31 +01:00
|
|
|
CategoryExists = &Error{
|
|
|
|
TemplateName: "error_category_exists",
|
2020-01-28 17:01:24 +01:00
|
|
|
Err: errors.New(i18n.Errors["categoryExists"]["it"]),
|
2019-12-09 14:18:31 +01:00
|
|
|
}
|
2020-01-27 11:43:56 +01:00
|
|
|
|
2019-12-29 17:23:50 +01:00
|
|
|
OutOfTime = &Error{
|
|
|
|
TemplateName: "error_out_of_time",
|
|
|
|
Err: errors.New(i18n.Errors["outOfTime"]["it"]),
|
|
|
|
}
|
2020-01-27 11:43:56 +01:00
|
|
|
|
|
|
|
ContestHasZeroQuestions = &Error{
|
|
|
|
TemplateName: "error_contest_has_zero_questions",
|
|
|
|
Err: errors.New(i18n.Errors["contestHasZeroQuestions"]["it"]),
|
|
|
|
}
|
2020-01-28 17:01:24 +01:00
|
|
|
|
|
|
|
QuestionsOrderIsEmpty = &Error{
|
|
|
|
TemplateName: "error_questions_order_is_empty",
|
|
|
|
Err: errors.New(i18n.Errors["questionsOrderIsEmpty"]["it"]),
|
|
|
|
}
|
2020-02-12 09:50:35 +01:00
|
|
|
|
|
|
|
WrongCaptcha = &Error{
|
|
|
|
TemplateName: "error_wrong_captcha",
|
|
|
|
Err: errors.New(i18n.Errors["wrongCaptcha"]["it"]),
|
|
|
|
}
|
2019-12-07 11:44:19 +01:00
|
|
|
)
|