Use fmt.Errorf
This commit is contained in:
parent
45069d4fbb
commit
adb424ea03
11 changed files with 50 additions and 60 deletions
|
@ -118,7 +118,7 @@ func exportResolutionMovies(_ httprouter.Params, body []byte) (interface{}, erro
|
|||
}
|
||||
}
|
||||
|
||||
func loadFlags(n func () ([]fic.Flag, error)) (interface{}, error) {
|
||||
func loadFlags(n func() ([]fic.Flag, error)) (interface{}, error) {
|
||||
if flags, err := n(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
|
@ -138,7 +138,7 @@ func loadFlags(n func () ([]fic.Flag, error)) (interface{}, error) {
|
|||
ret = append(ret, m)
|
||||
}
|
||||
} else {
|
||||
return nil, errors.New(fmt.Sprintf("Flag type %T not implemented for this flag.", f))
|
||||
return nil, fmt.Errorf("Flag type %T not implemented for this flag.", f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,11 +181,11 @@ type exerciceStats struct {
|
|||
|
||||
func getExerciceStats(e fic.Exercice, body []byte) (interface{}, error) {
|
||||
return exerciceStats{
|
||||
TeamTries: e.TriedTeamCount(),
|
||||
TotalTries: e.TriedCount(),
|
||||
TeamTries: e.TriedTeamCount(),
|
||||
TotalTries: e.TriedCount(),
|
||||
SolvedCount: e.SolvedCount(),
|
||||
FlagSolved: e.FlagSolved(),
|
||||
MCQSolved: e.MCQSolved(),
|
||||
FlagSolved: e.FlagSolved(),
|
||||
MCQSolved: e.MCQSolved(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -196,12 +196,12 @@ func getExercicesStats(_ httprouter.Params, body []byte) (interface{}, error) {
|
|||
ret := []exerciceStats{}
|
||||
for _, e := range exercices {
|
||||
ret = append(ret, exerciceStats{
|
||||
IdExercice: e.Id,
|
||||
TeamTries: e.TriedTeamCount(),
|
||||
TotalTries: e.TriedCount(),
|
||||
IdExercice: e.Id,
|
||||
TeamTries: e.TriedTeamCount(),
|
||||
TotalTries: e.TriedCount(),
|
||||
SolvedCount: e.SolvedCount(),
|
||||
FlagSolved: e.FlagSolved(),
|
||||
MCQSolved: e.MCQSolved(),
|
||||
FlagSolved: e.FlagSolved(),
|
||||
MCQSolved: e.MCQSolved(),
|
||||
})
|
||||
}
|
||||
return ret, nil
|
||||
|
@ -406,7 +406,7 @@ type uploadedFlag struct {
|
|||
ValidatorRe *string `json:"validator_regexp"`
|
||||
Flag string
|
||||
Value []byte
|
||||
ChoicesCost int64 `json:"choices_cost"`
|
||||
ChoicesCost int64 `json:"choices_cost"`
|
||||
}
|
||||
|
||||
func createExerciceFlag(exercice fic.Exercice, body []byte) (interface{}, error) {
|
||||
|
|
Reference in a new issue