Skip to content

Commit 180836e

Browse files
committed
adding more logging to mapping init func
so the log tells if it sails collecting mappings
1 parent c7109ab commit 180836e

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/HousesMapping.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"encoding/json"
55
"io/ioutil"
6+
"log"
67
)
78

89
var (
@@ -21,14 +22,22 @@ type HousesMapping struct {
2122
// TibiaDataHousesMappingInitiator func - used to load data from local JSON file
2223
func TibiaDataHousesMappingInitiator() {
2324
// load content from file into variable file
24-
file, _ := ioutil.ReadFile("houses_mapping.json")
25+
file, err := ioutil.ReadFile("houses_mapping.json")
2526

26-
// loading json and mapping it into the data variable
27-
data := HousesMapping{}
28-
_ = json.Unmarshal([]byte(file), &data)
27+
if err != nil {
28+
log.Println("[error] TibiaData API failed to load content from houses_mapping.json")
29+
} else {
30+
// loading json and mapping it into the data variable
31+
data := HousesMapping{}
32+
err = json.Unmarshal([]byte(file), &data)
2933

30-
// storing data so it's accessible from other places
31-
TibiadataHousesMapping = data
34+
if err != nil {
35+
log.Println("[error] TibiaData API failed to parse content from houses_mapping.json")
36+
} else {
37+
// storing data so it's accessible from other places
38+
TibiadataHousesMapping = data
39+
}
40+
}
3241
}
3342

3443
// TibiaDataHousesMapResolver func - used to return both town and type

0 commit comments

Comments
 (0)