Skip to content

Commit

Permalink
chore: remove panics
Browse files Browse the repository at this point in the history
  • Loading branch information
kldzj committed May 7, 2023
1 parent 7459d4d commit 4c0b3cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions steam/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"net/http"
"net/url"
"time"

"github.com/kldzj/pzmod/util"
"github.com/spf13/cobra"
)

const (
Expand All @@ -19,7 +22,7 @@ func SetApiKey(key string) {

func getApiKey() string {
if steamApiKey == "" {
panic("Steam API key not set")
cobra.CheckErr(util.ErrNoApiKey)
}

return steamApiKey
Expand All @@ -32,7 +35,7 @@ func newHttpClient() *http.Client {
func constructSteamApiUrl(path string) (*url.URL, *url.Values) {
url, err := url.Parse("https://api.steampowered.com" + path)
if err != nil {
panic(err)
cobra.CheckErr(err)
}

query := url.Query()
Expand Down
1 change: 1 addition & 0 deletions util/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ var (
ErrFileExists = errors.New("file already exists")
ErrInvalidKey = errors.New("invalid key")
ErrVerNotSet = errors.New("version not set")
ErrNoApiKey = errors.New("no Steam API key set")
)

0 comments on commit 4c0b3cf

Please sign in to comment.