Fix reporting image loading errors

This commit is contained in:
DarthSim
2023-08-01 19:48:10 +03:00
parent 35dcf5a261
commit a020a7603e
3 changed files with 8 additions and 3 deletions

View File

@@ -5,6 +5,9 @@
- Don't report `The image request is cancelled` errors.
- (pro) Change the `/info` endpoint behavior to return only the first EXIF/XMP/IPTC block data of JPEG if the image contains multiple metadata blocks of the same type.
### Fix
- Fix reporting image loading errors.
### Fix
- Fix the `Cache-Control` and `Expires` headers behavior when both `IMGPROXY_CACHE_CONTROL_PASSTHROUGH` and `IMGPROXY_FALLBACK_IMAGE_TTL` configs are set.
- (pro) Fix the `IMGPROXY_FALLBACK_IMAGE_TTL` config behavior when the `fallback_image_url` processing option is used.

View File

@@ -24,7 +24,7 @@ func LogResponse(reqID string, r *http.Request, status int, err *ierrors.Error,
var level log.Level
switch {
case status >= 500:
case status >= 500 || (err != nil && err.Unexpected):
level = log.ErrorLevel
case status >= 400:
level = log.WarnLevel

View File

@@ -155,12 +155,14 @@ func Error() error {
defer C.vips_error_clear()
errstr := strings.TrimSpace(C.GoString(C.vips_error_buffer()))
err := ierrors.NewUnexpected(errstr, 1)
if strings.Contains(errstr, "load_buffer: ") {
return ierrors.New(422, errstr, "Broken or unsupported image")
err.StatusCode = 422
err.PublicMessage = "Broken or unsupported image"
}
return ierrors.NewUnexpected(errstr, 1)
return err
}
func hasOperation(name string) bool {