Skip to content

Commit

Permalink
Added 'vidio: ' to error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexEidt committed Aug 29, 2023
1 parent 6b80253 commit 2c67651
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 121 deletions.
6 changes: 3 additions & 3 deletions camera.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (camera *Camera) FrameBuffer() []byte {
func (camera *Camera) SetFrameBuffer(buffer []byte) error {
size := camera.width * camera.height * camera.depth
if len(buffer) < size {
return fmt.Errorf("buffer size %d is smaller than frame size %d", len(buffer), size)
return fmt.Errorf("vidio: buffer size %d is smaller than frame size %d", len(buffer), size)
}
camera.framebuffer = buffer
return nil
Expand All @@ -86,11 +86,11 @@ func NewCamera(stream int) (*Camera, error) {
return nil, err
}
if stream < 0 || stream >= len(devices) {
return nil, fmt.Errorf("could not find device with index: %d", stream)
return nil, fmt.Errorf("vidio: could not find device with index: %d", stream)
}
device = fmt.Sprintf("video=%s", devices[stream])
default:
return nil, fmt.Errorf("unsupported OS: %s", runtime.GOOS)
return nil, fmt.Errorf("vidio: unsupported OS: %s", runtime.GOOS)
}

camera := &Camera{name: device, depth: 4}
Expand Down
4 changes: 2 additions & 2 deletions imageio.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Read(filename string, buffer ...[]byte) (int, int, []byte, error) {
var data []byte
if len(buffer) > 0 {
if len(buffer[0]) < size {
return 0, 0, nil, fmt.Errorf("buffer size (%d) is smaller than image size (%d)", len(buffer[0]), size)
return 0, 0, nil, fmt.Errorf("vidio: buffer size (%d) is smaller than image size (%d)", len(buffer[0]), size)
}
data = buffer[0]
} else {
Expand Down Expand Up @@ -68,6 +68,6 @@ func Write(filename string, width, height int, buffer []byte) error {
case ".jpg", ".jpeg":
return jpeg.Encode(f, image, nil)
default:
return fmt.Errorf("unsupported file extension: %s", filepath.Ext(filename))
return fmt.Errorf("vidio: unsupported file extension: %s", filepath.Ext(filename))
}
}
4 changes: 2 additions & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func installed(program string) error {
cmd := exec.Command(program, "-version")

if err := cmd.Run(); err != nil {
return fmt.Errorf("%s is not installed", program)
return fmt.Errorf("vidio: %s is not installed", program)
}

return nil
Expand Down Expand Up @@ -115,7 +115,7 @@ func webcam() (string, error) {
case "windows":
return "dshow", nil // vfwcap
default:
return "", fmt.Errorf("unsupported OS: %s", runtime.GOOS)
return "", fmt.Errorf("vidio: unsupported OS: %s", runtime.GOOS)
}
}

Expand Down
6 changes: 3 additions & 3 deletions video.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (video *Video) MetaData() map[string]string {
func (video *Video) SetFrameBuffer(buffer []byte) error {
size := video.width * video.height * video.depth
if len(buffer) < size {
return fmt.Errorf("buffer size %d is smaller than frame size %d", len(buffer), size)
return fmt.Errorf("vidio: buffer size %d is smaller than frame size %d", len(buffer), size)
}
video.framebuffer = buffer
return nil
Expand All @@ -110,7 +110,7 @@ func NewVideo(filename string) (*Video, error) {
// Read all video streams from the given file.
func NewVideoStreams(filename string) ([]*Video, error) {
if !exists(filename) {
return nil, fmt.Errorf("video file %s does not exist", filename)
return nil, fmt.Errorf("vidio: video file %s does not exist", filename)
}
// Check if ffmpeg and ffprobe are installed on the users machine.
if err := installed("ffmpeg"); err != nil {
Expand All @@ -126,7 +126,7 @@ func NewVideoStreams(filename string) ([]*Video, error) {
}

if len(videoData) == 0 {
return nil, fmt.Errorf("no video data found in %s", filename)
return nil, fmt.Errorf("vidio: no video data found in %s", filename)
}

// Loop over all stream types. a: Audio, s: Subtitle, d: Data, t: Attachments
Expand Down
2 changes: 1 addition & 1 deletion videowriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func NewVideoWriter(filename string, width, height int, options *Options) (*Vide

if options.StreamFile != "" {
if !exists(options.StreamFile) {
return nil, fmt.Errorf("file %s does not exist", options.StreamFile)
return nil, fmt.Errorf("vidio: file %s does not exist", options.StreamFile)
}
writer.streamfile = options.StreamFile
}
Expand Down
Loading

0 comments on commit 2c67651

Please sign in to comment.