From d77e12df7075e741176c04b4a7b3c7fff3816ed1 Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Fri, 21 Jun 2024 22:51:41 +0100 Subject: [PATCH] add an error for unspecified programs --- internal/utilities/utilities.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/utilities/utilities.go b/internal/utilities/utilities.go index 5e71636..5d3766e 100644 --- a/internal/utilities/utilities.go +++ b/internal/utilities/utilities.go @@ -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...)