Skip to content

Commit

Permalink
Merge pull request #13 from VATUSA/raaj
Browse files Browse the repository at this point in the history
remove deprecated func & better error logging
  • Loading branch information
Jonhasacat authored Jun 25, 2024
2 parents 544742a + fdfb772 commit 744bb6f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions internal/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
)

type ControllerDataWrapper struct {
Expand Down Expand Up @@ -43,9 +43,9 @@ func GetControllerData(discordId string) (*ControllerData, error) {
return nil, nil
}
if response.StatusCode != 200 {
return nil, errors.New("HTTP Error when fetching controller data")
return nil, errors.New(fmt.Sprintf("HTTP Error when fetching controller data: %d", response.StatusCode))
}
responseData, err := ioutil.ReadAll(response.Body)
responseData, err := io.ReadAll(response.Body)
if err != nil {
return nil, err
}
Expand Down
7 changes: 4 additions & 3 deletions internal/api/facility.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package api
import (
"encoding/json"
"errors"
"io/ioutil"
"fmt"
"io"
)

type FacilityData struct {
Expand All @@ -30,9 +31,9 @@ func GetFacilities() ([]FacilityData, error) {
return nil, nil
}
if response.StatusCode != 200 {
return nil, errors.New("HTTP Error when fetching facility data")
return nil, errors.New(fmt.Sprintf("HTTP Error when fetching facility data: %d", response.StatusCode))
}
responseData, err := ioutil.ReadAll(response.Body)
responseData, err := io.ReadAll(response.Body)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions internal/bot/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/VATUSA/discord-bot-v3/internal/config"
"github.com/VATUSA/discord-bot-v3/pkg/constants"
"gopkg.in/yaml.v3"
"io/ioutil"
"log"
"os"
"time"
Expand Down Expand Up @@ -68,7 +67,7 @@ func LoadAllServerConfig(configPath string) (map[string]ServerConfig, error) {
}

func LoadServerConfig(configPath string) (*ServerConfig, error) {
data, err := ioutil.ReadFile(configPath)
data, err := os.ReadFile(configPath)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 744bb6f

Please sign in to comment.