diff --git a/manager/middlewares/error.go b/manager/middlewares/error.go index c4c5c8d0573..a38d1fe7f6a 100644 --- a/manager/middlewares/error.go +++ b/manager/middlewares/error.go @@ -87,7 +87,7 @@ func Error() gin.HandlerFunc { // GORM error handler if errors.Is(err.Err, gorm.ErrRecordNotFound) { c.JSON(http.StatusNotFound, ErrorResponse{ - Message: http.StatusText(http.StatusNotFound), + Message: err.Error(), }) c.Abort() return diff --git a/manager/service/job.go b/manager/service/job.go index f68a445601b..f786eaaadff 100644 --- a/manager/service/job.go +++ b/manager/service/job.go @@ -186,7 +186,7 @@ func (s *service) findSchedulers(ctx context.Context, schedulerClusterIDs []uint for _, schedulerClusterID := range schedulerClusterIDs { schedulerCluster := models.SchedulerCluster{} if err := s.db.WithContext(ctx).First(&schedulerCluster, schedulerClusterID).Error; err != nil { - return nil, err + return nil, fmt.Errorf("scheduler cluster id %d: %w", schedulerClusterID, err) } var schedulers []models.Scheduler @@ -194,7 +194,7 @@ func (s *service) findSchedulers(ctx context.Context, schedulerClusterIDs []uint SchedulerClusterID: schedulerCluster.ID, State: models.SchedulerStateActive, }).Error; err != nil { - return nil, err + return nil, fmt.Errorf("scheduler cluster id %d: %w", schedulerClusterID, err) } activeSchedulers = append(activeSchedulers, schedulers...) @@ -233,7 +233,7 @@ func (s *service) findCandidateSchedulers(ctx context.Context, schedulerClusterI for _, schedulerClusterID := range schedulerClusterIDs { schedulerCluster := models.SchedulerCluster{} if err := s.db.WithContext(ctx).First(&schedulerCluster, schedulerClusterID).Error; err != nil { - return nil, err + return nil, fmt.Errorf("scheduler cluster id %d: %w", schedulerClusterID, err) } var schedulers []models.Scheduler @@ -241,7 +241,7 @@ func (s *service) findCandidateSchedulers(ctx context.Context, schedulerClusterI SchedulerClusterID: schedulerCluster.ID, State: models.SchedulerStateActive, }).Error; err != nil { - return nil, err + return nil, fmt.Errorf("scheduler cluster id %d: %w", schedulerClusterID, err) } for _, scheduler := range schedulers {