1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-11-27 22:48:53 +02:00

Respond with 422 on error during image loading

This commit is contained in:
DarthSim
2023-05-28 19:35:29 +03:00
parent 524434b63f
commit b3905c0cd3
2 changed files with 10 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ import (
"math"
"os"
"runtime"
"strings"
"sync"
"unsafe"
@@ -152,7 +153,14 @@ func Cleanup() {
func Error() error {
defer C.vips_error_clear()
return ierrors.NewUnexpected(C.GoString(C.vips_error_buffer()), 1)
errstr := strings.TrimSpace(C.GoString(C.vips_error_buffer()))
if strings.Contains(errstr, "load_buffer: ") {
return ierrors.New(422, errstr, "Broken or unsupported image")
}
return ierrors.NewUnexpected(errstr, 1)
}
func hasOperation(name string) bool {