~comcloudway/builds.sr.ht

89c87b209eef6c6460e84c5efb15a52d4ce92f32 — Simon Ser 1 year, 6 months ago 77b8066
api/loaders: don't panic

A panic here will take down the whole server: dataloaden spawns a
new goroutine and will not recover. (Regardless, an error can
happen here because of a runtime issue, so a panic is not a good
idea.)

See https://todo.sr.ht/~sircmpwn/sr.ht/325
1 files changed, 4 insertions(+), 4 deletions(-)

M api/loaders/middleware.go
M api/loaders/middleware.go => api/loaders/middleware.go +4 -4
@@ 65,7 65,7 @@ func fetchUsersByID(ctx context.Context) func(ids []int) ([]*model.User, []error

			return nil
		}); err != nil {
			panic(err)
			return nil, []error{err}
		}

		return users, nil


@@ 110,7 110,7 @@ func fetchUsersByName(ctx context.Context) func(names []string) ([]*model.User, 

			return nil
		}); err != nil {
			panic(err)
			return nil, []error{err}
		}

		return users, nil


@@ 155,7 155,7 @@ func fetchJobsByID(ctx context.Context) func(ids []int) ([]*model.Job, []error) 

			return nil
		}); err != nil {
			panic(err)
			return nil, []error{err}
		}

		return jobs, nil


@@ 200,7 200,7 @@ func fetchJobGroupsByID(ctx context.Context) func(ids []int) ([]*model.JobGroup,

			return nil
		}); err != nil {
			panic(err)
			return nil, []error{err}
		}

		return groups, nil