From bc7b9c58a8cb7e69eb45c2d6252a6a89130c7698 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 28 Apr 2024 18:11:27 -0400 Subject: [PATCH] Return error if icon theme could not be found --- icon-theme/icon-theme.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/icon-theme/icon-theme.go b/icon-theme/icon-theme.go index e8f3e0c..207dd1e 100644 --- a/icon-theme/icon-theme.go +++ b/icon-theme/icon-theme.go @@ -14,6 +14,8 @@ type iconThemeError string func (err iconThemeError) Error () string { return string(err) } const ( + // ErrThemeNotFound indicates that a theme could not be found. + ErrThemeNotFound = iconThemeError("theme not found") // ErrGroupMissing indicates that a required group was not found in an // index.theme file. ErrGroupMissing = iconThemeError("group missing") @@ -82,7 +84,7 @@ func findTheme (name string, trail []string, warn bool, path ...string) (Theme, } } - if path == nil { + if len(path) == 0 { themeDirs, err := ThemeDirs() if err != nil { return Theme { }, nil } path = themeDirs @@ -102,6 +104,7 @@ func findTheme (name string, trail []string, warn bool, path ...string) (Theme, } } } + if len(instances) == 0 { return Theme { }, ErrThemeNotFound } // find an index.theme var lastParseErr error @@ -149,7 +152,7 @@ func findTheme (name string, trail []string, warn bool, path ...string) (Theme, } // if no parents were successfuly parsed, inherit from hicolor - if theme.Inherits == nil && name != "hicolor" { + if len(theme.Inherits) == 0 && name != "hicolor" { hicolor, err := findTheme("hicolor", trail, warn, path...) if err != nil { return Theme { }, err } theme.Inherits = []Theme { hicolor }