#1277·kit

Add Error Handling for Canceled Contexts during request lifecycle

Author: gabizouCreated Oct 10, 2023Updated May 10, 2024

What would you like?

Various lifecycle steps can cancel a context.Context, but it would be the responsibility of each consumer to verify the context isn't canceled. It would be great to add:

go

	for _, f := range s.before {
		ctx = f(ctx, r)
		if ctx.Err() == context.Canceled {
			err := context.Cause(ctx)
			s.errorHandler.Handle(ctx, err)
			s.errorEncoder(ctx, err, w)
			return
		}
	}
	

	request, err := s.dec(ctx, r)
	if err != nil {
		s.errorHandler.Handle(ctx, err)
		s.errorEncoder(ctx, err, w)
		return
	}