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

Revised errors for better error reporting

This commit is contained in:
DarthSim
2025-02-17 22:11:40 +03:00
parent 204cfa3648
commit 528ece8da1
40 changed files with 844 additions and 434 deletions

View File

@@ -11,6 +11,7 @@ import (
"context"
"errors"
"math"
"net/http"
"os"
"regexp"
"runtime"
@@ -207,13 +208,15 @@ func Error() error {
defer C.vips_error_clear()
errstr := strings.TrimSpace(C.GoString(C.vips_error_buffer()))
err := ierrors.NewUnexpected(errstr, 1)
err := newVipsError(errstr)
for _, re := range badImageErrRe {
if re.MatchString(errstr) {
err.StatusCode = 422
err.PublicMessage = "Broken or unsupported image"
break
return ierrors.Wrap(
err, 0,
ierrors.WithStatusCode(http.StatusUnprocessableEntity),
ierrors.WithPublicMessage("Broken or unsupported image"),
)
}
}