1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-12-23 22:11:10 +02:00
Files
imgproxy/imagedata/errors.go
Sergei Aleksandrovich e33254005d Refactored errors (#1578)
* Refactored errors

* Make monitoring and errorreport accept `errctx.Error` instead of `error`

* Add server.Error; Remove category from errctx; Make HTTP handlers respond with *server.Error

* Remove stackSkip from errctx.Wrap; Add errctx.WrapWithStackSkip
2025-11-20 01:26:21 +06:00

29 lines
619 B
Go

package imagedata
import (
"fmt"
"net/http"
"github.com/imgproxy/imgproxy/v3/errctx"
"github.com/imgproxy/imgproxy/v3/fetcher"
)
type FileSizeError struct{ *errctx.TextError }
func newFileSizeError() error {
return FileSizeError{errctx.NewTextError(
"Source image file is too big",
1,
errctx.WithStatusCode(http.StatusUnprocessableEntity),
errctx.WithPublicMessage("Invalid source image"),
errctx.WithShouldReport(false),
)}
}
func wrapDownloadError(err error, desc string) error {
return errctx.Wrap(
fetcher.WrapError(err, 1),
errctx.WithPrefix(fmt.Sprintf("can't download %s", desc)),
)
}