56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package errors
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"git.andreafazzi.eu/andrea/oef/i18n"
|
|
)
|
|
|
|
type Error struct {
|
|
TemplateName string
|
|
Err error
|
|
Referer string
|
|
}
|
|
|
|
func (e *Error) Error() string {
|
|
return e.Err.Error()
|
|
}
|
|
|
|
var (
|
|
RecordExists = errors.New("Record already exists!")
|
|
|
|
NotAuthorized = &Error{
|
|
TemplateName: "error_not_authorized",
|
|
Err: errors.New(i18n.Authorization["notAuthorized"]["it"]),
|
|
}
|
|
|
|
SchoolExists = &Error{
|
|
TemplateName: "error_school_exists",
|
|
Err: errors.New(i18n.Errors["schoolExists"]["it"]),
|
|
}
|
|
|
|
ParticipantExists = &Error{
|
|
TemplateName: "error_participant_exists",
|
|
Err: errors.New(i18n.Errors["participantExists"]["it"]),
|
|
}
|
|
|
|
CategoryExists = &Error{
|
|
TemplateName: "error_category_exists",
|
|
Err: errors.New(i18n.Errors["categoryExists"]["it"]),
|
|
}
|
|
|
|
OutOfTime = &Error{
|
|
TemplateName: "error_out_of_time",
|
|
Err: errors.New(i18n.Errors["outOfTime"]["it"]),
|
|
}
|
|
|
|
ContestHasZeroQuestions = &Error{
|
|
TemplateName: "error_contest_has_zero_questions",
|
|
Err: errors.New(i18n.Errors["contestHasZeroQuestions"]["it"]),
|
|
}
|
|
|
|
QuestionsOrderIsEmpty = &Error{
|
|
TemplateName: "error_questions_order_is_empty",
|
|
Err: errors.New(i18n.Errors["questionsOrderIsEmpty"]["it"]),
|
|
}
|
|
)
|