diff --git a/tcl_stop.go b/tcl_stop.go index ceae384..bb840f9 100644 --- a/tcl_stop.go +++ b/tcl_stop.go @@ -58,15 +58,19 @@ func getPassages(ctx context.Context, config GrandLyonConfig, now func() time.Ti client = &http.Client{} } - var tclPassages TCLPassages + var ( + tclPassages TCLPassages + errResponse string + ) err := requests.URL("https://download.data.grandlyon.com/ws/rdata/tcl_sytral.tclpassagearret/all.json?maxfeatures=-1"). Client(client). + AddValidator(requests.ValidatorHandler(requests.DefaultValidator, requests.ToString(&errResponse))). BasicAuth(config.Username, config.Password). ToJSON(&tclPassages). Fetch(ctx) if err != nil { - return nil, fmt.Errorf("fetching passages: %w", err) + return nil, fmt.Errorf("fetching passages: %w (%v)", err, errResponse) } type passageKey struct { @@ -94,11 +98,12 @@ func getPassages(ctx context.Context, config GrandLyonConfig, now func() time.Ti err = requests.URL("https://download.data.grandlyon.com/ws/rdata/tcl_sytral.tclarret/all.json?maxfeatures=-1"). Client(client). + AddValidator(requests.ValidatorHandler(requests.DefaultValidator, requests.ToString(&errResponse))). BasicAuth(config.Username, config.Password). ToJSON(&tclStops). Fetch(ctx) if err != nil { - return nil, fmt.Errorf("fetching stops: %w", err) + return nil, fmt.Errorf("fetching stops: %w (%v)", err, errResponse) } updated := 0 diff --git a/velov.go b/velov.go index 7a49b4f..f77ebb5 100644 --- a/velov.go +++ b/velov.go @@ -31,13 +31,18 @@ type stationInfo struct { var errStationNotFound = errors.New("station not found") func getStation(ctx context.Context, client *http.Client, stationID int) (*Station, error) { - var info stationInfo + var ( + info stationInfo + errResponse string + ) + err := requests.URL("https://data.grandlyon.com/fr/datapusher/ws/rdata/jcd_jcdecaux.jcdvelov/all.json?maxfeatures=-1&start=1"). + AddValidator(requests.ValidatorHandler(requests.DefaultValidator, requests.ToString(&errResponse))). Client(client). ToJSON(&info). Fetch(ctx) if err != nil { - return nil, fmt.Errorf("querying station info: %w", err) + return nil, fmt.Errorf("querying station info: %w (%v)", err, errResponse) } station := Station{}