go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

feat. mapping Optimized error stack

Open reatang opened this issue 1 month ago • 1 comments

Optimize error returns to allow external parties to better judge errors

I can set an error handler to accurately handle error parameters with a single judgment.

httpx.SetErrorHandler(func(err error) (int, any) {
      if errors.Is(err, mapping.ErrMappingErrors) {
	      return http.StatusBadRequest, nil
      }
      
      return http.StatusInternalServerError, nil
})


reatang avatar Jun 04 '24 06:06 reatang