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
|
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...)
|
||||||
|
|
Loading…
Reference in a new issue