add an error for unspecified programs
This commit is contained in:
parent
3ef8164b48
commit
d77e12df70
1 changed files with 7 additions and 2 deletions
|
@ -5,7 +5,6 @@
|
|||
package utilities
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
|
@ -17,9 +16,15 @@ func GetFQDN(url string) string {
|
|||
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 {
|
||||
if viewer == "" {
|
||||
return errors.New("the image viewer is not specified")
|
||||
return UnspecifiedProgramError{}
|
||||
}
|
||||
|
||||
command := exec.Command(viewer, paths...)
|
||||
|
|
Loading…
Reference in a new issue