Return error if icon theme could not be found

This commit is contained in:
Sasha Koshka 2024-04-28 18:11:27 -04:00
parent d82e802563
commit bc7b9c58a8

View File

@ -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 }