Skip to content
Snippets Groups Projects
Unverified Commit b00fc45c authored by Kevin Lyda's avatar Kevin Lyda
Browse files

Clean up error handling.

parent bf11addd
No related branches found
No related tags found
No related merge requests found
...@@ -30,24 +30,7 @@ func handleCommands() { ...@@ -30,24 +30,7 @@ func handleCommands() {
func Run(cmd *cobra.Command, args []string) { func Run(cmd *cobra.Command, args []string) {
viper.BindPFlags(cmd.Flags()) viper.BindPFlags(cmd.Flags())
cfg, err := config.ReadConfig(viper.GetString("config")) cfg, err := config.ReadConfig(viper.GetString("config"))
if err != nil {
// TODO Make a better default
cfg, err = config.ReadConfigStr(`---
refresh: 5
modules:
- module: text
name: post
params:
text: "post"
color: "#11ff11"
on-click: xdg-open https://mastodon.ie/
- module: date
params:
format: 06-05-04 15:02
on-click: xdg-open https://calendar.google.com/
`)
cobra.CheckErr(err) cobra.CheckErr(err)
}
if cfg.Refresh < 1 { if cfg.Refresh < 1 {
cfg.Refresh = 5 cfg.Refresh = 5
} }
......
package modules package modules
import ( import (
"fmt"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
) )
...@@ -41,7 +43,7 @@ func (m *Module) UnmarshalYAML(node *yaml.Node) error { ...@@ -41,7 +43,7 @@ func (m *Module) UnmarshalYAML(node *yaml.Node) error {
case "text": case "text":
m.Params = NewText(m) m.Params = NewText(m)
default: default:
panic("module unknown") return fmt.Errorf("module '%s' is unknown", params.Module)
} }
return params.Params.Decode(m.Params) return params.Params.Decode(m.Params)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment