Checks for Garmin weather data

Hello,

I use Garmin weather in my watchfaces and they work just fine on my F6X Sapphire in The Netherlands, but some users reporting IQ! errors which I cannot reproduce myself.

The ERA logs initially pointed to probably missing weather forecast data, so I added some checks for this, see the 1st row in the example below. This helped up to some extent, but new kind of error happens sometimes now when the first arithmetic etc. operations applied to the content of the temperature field, like in the "if (weather_currT > 0) {" string of the example below:

if(Weather.getCurrentConditions() != null and Weather.getCurrentConditions() has :temperature) {
	        var weather_currT = Weather.getCurrentConditions().temperature;
			   	if (weather_currT > 0) {
			   	// do something
			   }	

The ERA log says:

Error Name: Unhandled Exception
Occurrences: 182
First Occurrence: 2021-02-14
Last Occurrence: 2021-02-21
Devices:
    fēnix® 6 / 6 Solar / 6 Dual Power: 13.30
    fēnix® 6 Pro / 6 Sapphire / 6 Pro Solar / 6 Pro Dual Power / quatix® 6: 15.01, 13.10, 15.20
    fēnix® 6S Pro / 6S Sapphire / 6S Pro Solar / 6S Pro Dual Power: 13.10
    MARQâ„¢ Adventurer: 13.10
    fēnix® 6X Pro / 6X Sapphire / 6X Pro Solar / tactix® Delta Sapphire / Delta Solar / Delta Solar - Ballistics Edition / quatix® 6X / 6X Solar / 6X Dual Power: 13.10, 15.20
    Forerunner® 945: 5.50
App Versions: 1.0.7.1
Languages: bul, ces, deu, dut, eng, fre, heb, hrv, ita, pol, por, ron, rus, slo, spa
Backtrace:
    EllipsesView.drawWeatherC:299
    EllipsesView.onUpdate:196

What could be a reason for this error?

Should I also add a check for the content of the .temperature data? I.e. if it is a number and not a string?

Thank you.

  • Checking for null if something can be null is really standard though.

    Right, this seems to be not a kind of insight Slight smile

    I refer to the whole weather check flow: at which level "has" to be used and when null check comes to the place.

  • Much of what you ran into can be tested in the sim.  Try targets that you know don't have Weather, and in the sim, settings>set weather, uncheck "Weather Data Available"

    I do "has" differently than Travis posted, as I do all my has checks when an app starts, and then set a boolean, and later check that boolean, as it's "cheaper" than doing a has all the time.

    There is a learning curve with CIQ, and no easy way to avoid it.

  • There is a learning curve with CIQ, and no easy way to avoid it.

    Indeed.

    But I believe that there are some ways to shorten it ;)