Skip to content

Commit

Permalink
Panic if an unknown widget is requested
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Jul 19, 2019
1 parent 307cf96 commit 8b18374
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func NewWidget(index uint8, id string, action *ActionConfig, config map[string]s
bw := BaseWidget{index, action}

switch id {
case "button":
return &ButtonWidget{BaseWidget: bw, icon: config["icon"], label: config["label"]}
case "clock":
return &ClockWidget{bw}
case "recentWindow":
i, err := strconv.ParseUint(config["window"], 10, 64)
if err != nil {
Expand All @@ -58,12 +62,9 @@ func NewWidget(index uint8, id string, action *ActionConfig, config map[string]s
return &RecentWindowWidget{BaseWidget: bw, window: uint8(i)}
case "top":
return &TopWidget{bw}
case "clock":
return &ClockWidget{bw}
case "launcher":
return &LauncherWidget{BaseWidget: bw, launch: config["exec"], icon: config["icon"]}
}

panic(id)
return nil
}

Expand Down

0 comments on commit 8b18374

Please sign in to comment.