Capitalize error messages according to staticcheck
This commit is contained in:
parent
e3b69e8f83
commit
30f5497aa5
7 changed files with 48 additions and 48 deletions
|
@ -37,7 +37,7 @@ func (r *OfficeHourRepo) GetAll(activeOnly bool) ([]models.OfficeHour, error) {
|
|||
rows, err = r.db.Query("SELECT * FROM officeHour")
|
||||
}
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error getting all officeHours from database: %w", err)
|
||||
err = fmt.Errorf("error getting all officeHours from database: %w", err)
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
log.Println(err.Error())
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ func (r *OfficeHourRepo) FindByCourse(course models.Course, activeOnly bool) ([]
|
|||
}
|
||||
defer rows.Close()
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error getting officeHours by course from database: %w", err)
|
||||
err = fmt.Errorf("error getting officeHours by course from database: %w", err)
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
log.Println(err.Error())
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func (r *OfficeHourRepo) FindByRoom(room models.Room, activeOnly bool) ([]models
|
|||
rows, err = r.db.Query("SELECT * FROM officeHour WHERE room=?", room.Id)
|
||||
}
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error getting officeHours by room from database: %w", err)
|
||||
err = fmt.Errorf("error getting officeHours by room from database: %w", err)
|
||||
if !errors.Is(err, sql.ErrNoRows) {
|
||||
log.Println(err.Error())
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ func (r *OfficeHourRepo) Add(officeHour models.OfficeHour) (int, error) {
|
|||
}
|
||||
officeHour.Tutor, err = r.tutorRepo.FindByNameAndEmail(officeHour.Tutor.Name, officeHour.Tutor.Email)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Newly added tutor not found: %w", err)
|
||||
err = fmt.Errorf("newly added tutor not found: %w", err)
|
||||
log.Println(err.Error())
|
||||
return 0, err
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ func (r *OfficeHourRepo) Add(officeHour models.OfficeHour) (int, error) {
|
|||
}
|
||||
id, lastInsertIdErr := sqlResult.LastInsertId()
|
||||
if lastInsertIdErr != nil {
|
||||
log.Printf("Error getting Id for new tutor: %s", lastInsertIdErr.Error())
|
||||
log.Printf("error getting Id for new tutor: %s", lastInsertIdErr.Error())
|
||||
}
|
||||
return int(id), err
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ func (r *OfficeHourRepo) Add(officeHour models.OfficeHour) (int, error) {
|
|||
func (r *OfficeHourRepo) Delete(officeHour models.OfficeHour) error {
|
||||
_, err := r.db.Exec("DELETE FROM officeHour WHERE id=?", officeHour.Id)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error deleting officeHour from database: %w", err)
|
||||
err = fmt.Errorf("error deleting officeHour from database: %w", err)
|
||||
log.Println(err.Error())
|
||||
return err
|
||||
}
|
||||
|
@ -160,26 +160,26 @@ func (r *OfficeHourRepo) getFromRow(row *sql.Row) (models.OfficeHour, error) {
|
|||
var week, day, hour, minute, tutorId, courseId, roomId int
|
||||
err := row.Scan(&officeHour.Id, &tutorId, &day, &hour, &minute, &roomId, &officeHour.RoomName, &courseId, &week, &officeHour.Info, &officeHour.Active, &officeHour.Duration)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error getting single officeHour row from database: %w", err)
|
||||
err = fmt.Errorf("error getting single officeHour row from database: %w", err)
|
||||
log.Println(err.Error())
|
||||
return models.OfficeHour{}, err
|
||||
}
|
||||
officeHour.Date = models.Date{Week: week, Day: day, Hour: hour, Minute: minute}
|
||||
officeHour.Room, err = r.roomRepo.FindById(roomId)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error finding room by id %d for office hour: %w", roomId, err)
|
||||
err = fmt.Errorf("error finding room by id %d for office hour: %w", roomId, err)
|
||||
log.Println(err.Error())
|
||||
return officeHour, err
|
||||
}
|
||||
officeHour.Tutor, err = r.tutorRepo.FindById(tutorId)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error finding tutor by id %d for office hour: %w", tutorId, err)
|
||||
err = fmt.Errorf("error finding tutor by id %d for office hour: %w", tutorId, err)
|
||||
log.Println(err.Error())
|
||||
return officeHour, err
|
||||
}
|
||||
officeHour.Course, err = r.courseRepo.FindById(courseId)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error finding course by id %d for office hour: %w", courseId, err)
|
||||
err = fmt.Errorf("error finding course by id %d for office hour: %w", courseId, err)
|
||||
log.Println(err.Error())
|
||||
return officeHour, err
|
||||
}
|
||||
|
@ -193,24 +193,24 @@ func (r *OfficeHourRepo) getFromRows(rows *sql.Rows) ([]models.OfficeHour, error
|
|||
var week, day, hour, minute, tutorId, roomId, courseId int
|
||||
var err error
|
||||
if err := rows.Scan(&officeHour.Id, &tutorId, &day, &hour, &minute, &roomId, &officeHour.RoomName, &courseId, &week, &officeHour.Info, &officeHour.Active, &officeHour.Duration); err != nil {
|
||||
return officeHours, fmt.Errorf("Error getting multiple officeHour rows from database: %w", err)
|
||||
return officeHours, fmt.Errorf("error getting multiple officeHour rows from database: %w", err)
|
||||
}
|
||||
officeHour.Date = models.Date{Week: week, Day: day, Hour: hour, Minute: minute}
|
||||
officeHour.Room, err = r.roomRepo.FindById(roomId)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error finding room by id %d for office hour: %w", roomId, err)
|
||||
err = fmt.Errorf("error finding room by id %d for office hour: %w", roomId, err)
|
||||
log.Println(err.Error())
|
||||
return officeHours, err
|
||||
}
|
||||
officeHour.Tutor, err = r.tutorRepo.FindById(tutorId)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error finding tutor by id %d for office hour: %w", tutorId, err)
|
||||
err = fmt.Errorf("error finding tutor by id %d for office hour: %w", tutorId, err)
|
||||
log.Println(err.Error())
|
||||
return officeHours, err
|
||||
}
|
||||
officeHour.Course, err = r.courseRepo.FindById(courseId)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error finding course by id %d for office hour: %w", courseId, err)
|
||||
err = fmt.Errorf("error finding course by id %d for office hour: %w", courseId, err)
|
||||
log.Println(err.Error())
|
||||
return officeHours, err
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ func (r *OfficeHourRepo) NumberByTimeSpanAndRoom(date models.Date, duration int,
|
|||
rows, err = r.db.Query("SELECT * FROM officeHour WHERE room=?", room.Id)
|
||||
}
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error getting officeHours by timespan and room from database: %w", err)
|
||||
err = fmt.Errorf("error getting officeHours by timespan and room from database: %w", err)
|
||||
log.Println(err.Error())
|
||||
return 0, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue