Skip to content

Commit

Permalink
Use fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
hexbabe committed Jan 29, 2025
1 parent ce6477b commit ebcc783
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mime.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import "C"
import (
"encoding/binary"
"errors"
"fmt"
"sync"
"unsafe"

Expand Down Expand Up @@ -166,7 +167,7 @@ func (mh *mimeHandler) convertPixelFormat(
mimeType string,
) ([]byte, camera.ImageMetadata, error) {
if frame == nil {
return nil, camera.ImageMetadata{}, errors.New("frame input is nil, cannot convert to " + format)
return nil, camera.ImageMetadata{}, fmt.Errorf("frame input is nil, cannot convert to %s", format)
}

mu.Lock()
Expand All @@ -179,10 +180,10 @@ func (mh *mimeHandler) convertPixelFormat(
}

if *swsCtx == nil {
return nil, camera.ImageMetadata{}, errors.New("failed to create " + format + " converter")
return nil, camera.ImageMetadata{}, fmt.Errorf("failed to create %s converter", format)
}
if *dstFrame == nil {
return nil, camera.ImageMetadata{}, errors.New("failed to create " + format + " destination frame")
return nil, camera.ImageMetadata{}, fmt.Errorf("failed to create %s destination frame", format)
}

res := C.sws_scale(
Expand All @@ -195,7 +196,7 @@ func (mh *mimeHandler) convertPixelFormat(
(*C.int)(unsafe.Pointer(&(*dstFrame).linesize[0])),
)
if res < 0 {
return nil, camera.ImageMetadata{}, newAvError(res, "failed to convert frame to "+format)
return nil, camera.ImageMetadata{}, newAvError(res, "failed to convert frame to " + format)
}

dataSize := int((*dstFrame).width) * int((*dstFrame).height) * bytesPerPixel
Expand Down

0 comments on commit ebcc783

Please sign in to comment.