errors.go 837 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package imagemeta
  2. import (
  3. "fmt"
  4. "net/http"
  5. "github.com/imgproxy/imgproxy/v3/ierrors"
  6. )
  7. type (
  8. UnknownFormatError struct{}
  9. FormatError string
  10. )
  11. func newUnknownFormatError() error {
  12. return ierrors.Wrap(
  13. UnknownFormatError{},
  14. 1,
  15. ierrors.WithStatusCode(http.StatusUnprocessableEntity),
  16. ierrors.WithPublicMessage("Invalid source image"),
  17. ierrors.WithShouldReport(false),
  18. )
  19. }
  20. func (e UnknownFormatError) Error() string { return "Source image type not supported" }
  21. func newFormatError(format, msg string) error {
  22. return ierrors.Wrap(
  23. FormatError(fmt.Sprintf("Invalid %s file: %s", format, msg)),
  24. 1,
  25. ierrors.WithStatusCode(http.StatusUnprocessableEntity),
  26. ierrors.WithPublicMessage("Invalid source image"),
  27. ierrors.WithShouldReport(false),
  28. )
  29. }
  30. func (e FormatError) Error() string { return string(e) }