Files
QSfera/vendor/github.com/davidbyttow/govips/v2/vips/error.go
T
Ralf HaferkampandRalf Haferkamp a9a5570050 feat(thumbnails): optional libvips based thumbnail generation
Can be enabled by setting the 'enable_vips' tag on 'go build'
2024-10-17 14:05:27 +02:00

40 lines
640 B
Go

package vips
// #include <vips/vips.h>
import "C"
import (
"errors"
"fmt"
dbg "runtime/debug"
"unsafe"
)
var (
// ErrUnsupportedImageFormat when image type is unsupported
ErrUnsupportedImageFormat = errors.New("unsupported image format")
)
func handleImageError(out *C.VipsImage) error {
if out != nil {
clearImage(out)
}
return handleVipsError()
}
func handleSaveBufferError(out unsafe.Pointer) error {
if out != nil {
gFreePointer(out)
}
return handleVipsError()
}
func handleVipsError() error {
s := C.GoString(C.vips_error_buffer())
C.vips_error_clear()
return fmt.Errorf("%v\nStack:\n%s", s, dbg.Stack())
}