Skip to content

Commit

Permalink
some additional logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jzyinq committed May 5, 2024
1 parent a4f2545 commit 81a38a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions gojira/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ var WorklogsCommand = &cli.Command{
defer wg.Done()
countryCode, err := GetCountryFromLCTime(os.Getenv("LC_TIME"))
if err != nil {
app.ui.errorView.ShowError("Error getting country code from LC_TIME:" + err.Error())
logrus.Error(err)
logrus.Error("getting country code from LC_TIME failed:" + err.Error())
}
app.holidays, err = NewHolidays(countryCode)
if err != nil {
app.ui.errorView.ShowError(err.Error())
logrus.Error("fetching national holidays failed:" + err.Error())
}
logrus.Error("Holidays loaded")
}()
wg.Wait()
err := app.ui.app.Run()
Expand Down
6 changes: 3 additions & 3 deletions gojira/hoilidays.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ func (h *Holiday) GetTime() (*time.Time, error) {

func getHolidaysForCountry(countryCode string) (*Holidays, error) {
url := fmt.Sprintf("https://date.nager.at/api/v3/PublicHolidays/2024/%s", countryCode)
logrus.Infof("fetching holidays from url: %s", url)
resp, err := http.Get(url) //nolint:gosec
if err != nil {
logrus.Error(err)
logrus.Error("could not fetch holidays from url: ", url)
return nil, err
}
defer resp.Body.Close()
var holidays Holidays
err = json.NewDecoder(resp.Body).Decode(&holidays)
if err != nil {
logrus.Error(err)
return nil, err
}
return &holidays, nil
Expand All @@ -76,7 +76,7 @@ func NewHolidays(countryCode string) (*Holidays, error) {
holidays, err := getHolidaysForCountry(countryCode)
if err != nil {
logrus.Error(err)
return nil, err
return &Holidays{}, err
}

return holidays, nil
Expand Down

0 comments on commit 81a38a1

Please sign in to comment.