add an error for unspecified programs

This commit is contained in:
Dan Anglin 2024-06-21 22:51:41 +01:00
parent 3ef8164b48
commit d77e12df70
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638

View file

@ -5,7 +5,6 @@
package utilities package utilities
import ( import (
"errors"
"fmt" "fmt"
"os/exec" "os/exec"
"regexp" "regexp"
@ -17,9 +16,15 @@ func GetFQDN(url string) string {
return r.ReplaceAllString(url, "") return r.ReplaceAllString(url, "")
} }
type UnspecifiedProgramError struct{}
func (e UnspecifiedProgramError) Error() string {
return "the program to view these files is unspecified"
}
func OpenMedia(viewer string, paths []string) error { func OpenMedia(viewer string, paths []string) error {
if viewer == "" { if viewer == "" {
return errors.New("the image viewer is not specified") return UnspecifiedProgramError{}
} }
command := exec.Command(viewer, paths...) command := exec.Command(viewer, paths...)