File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package main
3
3
import (
4
4
"encoding/json"
5
5
"io/ioutil"
6
+ "log"
6
7
)
7
8
8
9
var (
@@ -21,14 +22,22 @@ type HousesMapping struct {
21
22
// TibiaDataHousesMappingInitiator func - used to load data from local JSON file
22
23
func TibiaDataHousesMappingInitiator () {
23
24
// load content from file into variable file
24
- file , _ := ioutil .ReadFile ("houses_mapping.json" )
25
+ file , err := ioutil .ReadFile ("houses_mapping.json" )
25
26
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 )
29
33
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
+ }
32
41
}
33
42
34
43
// TibiaDataHousesMapResolver func - used to return both town and type
You can’t perform that action at this time.
0 commit comments