@@ -2,6 +2,7 @@ package api
22
33import (
44 "encoding/json"
5+ "errors"
56 "fmt"
67 "strings"
78)
@@ -224,15 +225,15 @@ type RemoteHvacInfo struct {
224225// GetInternalVIN extracts the internal VIN from the first vehicle in the response
225226func (r * VecBaseInfosResponse ) GetInternalVIN () (string , error ) {
226227 if len (r .VecBaseInfos ) == 0 {
227- return "" , fmt . Errorf ("no vehicles found" )
228+ return "" , errors . New ("no vehicles found" )
228229 }
229230 return string (r .VecBaseInfos [0 ].Vehicle .CvInformation .InternalVIN ), nil
230231}
231232
232233// GetVehicleInfo extracts vehicle identification info from the response
233234func (r * VecBaseInfosResponse ) GetVehicleInfo () (vin , nickname , modelName , modelYear string , err error ) {
234235 if len (r .VecBaseInfos ) == 0 {
235- err = fmt . Errorf ("no vehicles found" )
236+ err = errors . New ("no vehicles found" )
236237 return
237238 }
238239 info := r .VecBaseInfos [0 ]
@@ -247,7 +248,7 @@ func (r *VecBaseInfosResponse) GetVehicleInfo() (vin, nickname, modelName, model
247248// GetBatteryInfo extracts battery information from the EV status response
248249func (r * EVVehicleStatusResponse ) GetBatteryInfo () (BatteryInfo , error ) {
249250 if len (r .ResultData ) == 0 {
250- return BatteryInfo {}, fmt . Errorf ("no EV status data available" )
251+ return BatteryInfo {}, errors . New ("no EV status data available" )
251252 }
252253 chargeInfo := r .ResultData [0 ].PlusBInformation .VehicleInfo .ChargeInfo
253254 return BatteryInfo {
@@ -265,11 +266,11 @@ func (r *EVVehicleStatusResponse) GetBatteryInfo() (BatteryInfo, error) {
265266// GetHvacInfo extracts HVAC information from the EV status response
266267func (r * EVVehicleStatusResponse ) GetHvacInfo () (HVACInfo , error ) {
267268 if len (r .ResultData ) == 0 {
268- return HVACInfo {}, fmt . Errorf ("no EV status data available" )
269+ return HVACInfo {}, errors . New ("no EV status data available" )
269270 }
270271 hvacInfo := r .ResultData [0 ].PlusBInformation .VehicleInfo .RemoteHvacInfo
271272 if hvacInfo == nil {
272- return HVACInfo {}, fmt . Errorf ("no HVAC info available" )
273+ return HVACInfo {}, errors . New ("no HVAC info available" )
273274 }
274275 return HVACInfo {
275276 HVACOn : int (hvacInfo .HVAC ) == HVACStatusOn ,
@@ -283,15 +284,15 @@ func (r *EVVehicleStatusResponse) GetHvacInfo() (HVACInfo, error) {
283284// GetOccurrenceDate returns the occurrence date from the first result
284285func (r * EVVehicleStatusResponse ) GetOccurrenceDate () (string , error ) {
285286 if len (r .ResultData ) == 0 {
286- return "" , fmt . Errorf ("no EV status data available" )
287+ return "" , errors . New ("no EV status data available" )
287288 }
288289 return r .ResultData [0 ].OccurrenceDate , nil
289290}
290291
291292// GetFuelInfo extracts fuel information from the vehicle status response
292293func (r * VehicleStatusResponse ) GetFuelInfo () (FuelInfo , error ) {
293294 if len (r .RemoteInfos ) == 0 {
294- return FuelInfo {}, fmt . Errorf ("no vehicle status data available" )
295+ return FuelInfo {}, errors . New ("no vehicle status data available" )
295296 }
296297 fuel := r .RemoteInfos [0 ].ResidualFuel
297298 return FuelInfo {
@@ -303,7 +304,7 @@ func (r *VehicleStatusResponse) GetFuelInfo() (FuelInfo, error) {
303304// GetTiresInfo extracts tire pressure information from the vehicle status response
304305func (r * VehicleStatusResponse ) GetTiresInfo () (TireInfo , error ) {
305306 if len (r .RemoteInfos ) == 0 {
306- return TireInfo {}, fmt . Errorf ("no vehicle status data available" )
307+ return TireInfo {}, errors . New ("no vehicle status data available" )
307308 }
308309 tpms := r .RemoteInfos [0 ].TPMSInformation
309310 return TireInfo {
@@ -317,7 +318,7 @@ func (r *VehicleStatusResponse) GetTiresInfo() (TireInfo, error) {
317318// GetLocationInfo extracts location information from the vehicle status response
318319func (r * VehicleStatusResponse ) GetLocationInfo () (LocationInfo , error ) {
319320 if len (r .AlertInfos ) == 0 {
320- return LocationInfo {}, fmt . Errorf ("no alert info available" )
321+ return LocationInfo {}, errors . New ("no alert info available" )
321322 }
322323 pos := r .AlertInfos [0 ].PositionInfo
323324 return LocationInfo {
@@ -401,7 +402,7 @@ type HVACInfo struct {
401402// GetDoorsInfo extracts door lock status from the vehicle status response
402403func (r * VehicleStatusResponse ) GetDoorsInfo () (status DoorStatus , err error ) {
403404 if len (r .AlertInfos ) == 0 {
404- err = fmt . Errorf ("no alert info available" )
405+ err = errors . New ("no alert info available" )
405406 return
406407 }
407408 door := r .AlertInfos [0 ].Door
@@ -434,7 +435,7 @@ func (r *VehicleStatusResponse) GetDoorsInfo() (status DoorStatus, err error) {
434435// GetOdometerInfo extracts odometer reading from the vehicle status response
435436func (r * VehicleStatusResponse ) GetOdometerInfo () (OdometerInfo , error ) {
436437 if len (r .RemoteInfos ) == 0 {
437- return OdometerInfo {}, fmt . Errorf ("no vehicle status data available" )
438+ return OdometerInfo {}, errors . New ("no vehicle status data available" )
438439 }
439440 return OdometerInfo {
440441 OdometerKm : r .RemoteInfos [0 ].DriveInformation .OdoDispValue ,
@@ -444,7 +445,7 @@ func (r *VehicleStatusResponse) GetOdometerInfo() (OdometerInfo, error) {
444445// GetWindowsInfo extracts window position information from the vehicle status response
445446func (r * VehicleStatusResponse ) GetWindowsInfo () (WindowStatus , error ) {
446447 if len (r .AlertInfos ) == 0 {
447- return WindowStatus {}, fmt . Errorf ("no alert info available" )
448+ return WindowStatus {}, errors . New ("no alert info available" )
448449 }
449450 pw := r .AlertInfos [0 ].Pw
450451 return WindowStatus {
@@ -458,7 +459,7 @@ func (r *VehicleStatusResponse) GetWindowsInfo() (WindowStatus, error) {
458459// GetHazardInfo extracts hazard lights status from the vehicle status response
459460func (r * VehicleStatusResponse ) GetHazardInfo () (hazardsOn bool , err error ) {
460461 if len (r .AlertInfos ) == 0 {
461- err = fmt . Errorf ("no alert info available" )
462+ err = errors . New ("no alert info available" )
462463 return
463464 }
464465 hazardsOn = int (r .AlertInfos [0 ].HazardLamp .HazardSw ) == HazardLightsOn
0 commit comments