forked from jason/cpolis
Show error messages in UI if something goes wrong
This commit is contained in:
@ -2,6 +2,7 @@ package backend
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
@ -10,9 +11,14 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
var ErrUnsupportedFormat error = image.ErrFormat // used internally by imaging
|
||||
|
||||
func SaveImage(c *Config, src io.Reader) (string, error) {
|
||||
img, err := imaging.Decode(src, imaging.AutoOrientation(true))
|
||||
if err != nil {
|
||||
if err == ErrUnsupportedFormat {
|
||||
return "", ErrUnsupportedFormat
|
||||
}
|
||||
return "", fmt.Errorf("error decoding image: %v", err)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user