Garmin Weather App Crash

I have a FR745 running beta 4.85.  Ever since I upgraded to the beta when I turn the watch off and back on my watch face crashes on boot up and goes to the default on the FR745.  If I move down to the widgets and back up it will reappear with all data showing.  It sometimes takes a couple times but it always starts working.  I have got it down to 1 line of code that is causing the issue.  Take it out works fine...put it back it crashes.  This is the only code the function except a return "1" which shows after I move off the watch face and back.  I did also try to put in a try/catch but it did not change anything.    I am doing a has weather check before I call the function and was doing a check for null however I have taken all of that out and am not trying to return vTempF or do anything with it.  Just attempting to make the call to Weather.getCurrentConditions().temperature and put it into a var causes the issue.

Any thoughts on what could be causing this.

var vTempF = Weather.getCurrentConditions().temperature;

log file

Error: Unexpected Type Error
Details: 'Failed invoking <symbol>'
Time: 2021-05-26T15:15:32Z
Part-Number: 006-B3589-00
Firmware-Version: '4.85'
Language-Code: eng
ConnectIQ-Version: 3.2.5
Filename: WatchFace
Appname:WatchFace
Stack:
  - pc: 0x100018d7
    File: ....WatchFaceView.mc'
    Line: 292
    Function: valTempF
  - pc: 0x10000d5f
    File: ....WatchFaceView.mc'
    Line: 107
    Function: onUpdate

  • Did you also null check for

    Weather.getCurrentConditions()

    Before calling .temperature ?

    Did you déclare Toybox.Weather ? 

  • Sounds like you aren't doing null checks when you should.  You want to null check the return from getCurrentConditions() (and others) as when you first turn on the watch, it won't have any data.  You also want to null check things in the current conditions.

    CurrentConditions  

    or null if no data is available

    and for things in current conditions:

    temperature as Number or Null

  • Yes. Toy box.Weather is declared.  

    Hmm. My null check is on .temp. I will put it on get Current first.

  • Well. That was it.  Why wouldn’t Garmin just give you back null and let me deal with it from there....

    So do I have to test null for just getCurrent or do I have to test on both getCurrent and getCurrent...temperature 

  • Hi, as Jim said, Both of them, for some reason, temp can also be null. 

  • Thank you guys for the help.  One last question.  Which method do you prefer?    

    hidden function valTempF() {
    if (Weather.getCurrentConditions() != null) {
    var vTempF = Weather.getCurrentConditions().temperature;
    if (vTempF!=null) {
    return (vTempF*(9.0/5)+32.5).format("%d")+"°".toString();


    hidden function valTempF() {
    if (Weather.getCurrentConditions()!=null&&Weather.getCurrentConditions().temperature!=null) {
    var vTempF = Weather.getCurrentConditions().temperature;
    return (vTempF*(9.0/5)+32.5).format("%d")+"°".toString();

    hidden function valTempF() {
    if (Weather.getCurrentConditions() != null) {
    if Weather.getCurrentConditions().temperature!=null {
    var vTempF = Weather.getCurrentConditions().temperature;
    return (vTempF*(9.0/5)+32.5).format("%d")+"°".toString();

  • I posted this in reply to your post as well.  Not sure you would see the other one.

    Thank you guys for the help.  One last question.  Which method do you prefer?    

    hidden function valTempF() {
    if (Weather.getCurrentConditions() != null) {
    var vTempF = Weather.getCurrentConditions().temperature;
    if (vTempF!=null) {
    return (vTempF*(9.0/5)+32.5).format("%d")+"°".toString();


    hidden function valTempF() {
    if (Weather.getCurrentConditions()!=null&&Weather.getCurrentConditions().temperature!=null) {
    var vTempF = Weather.getCurrentConditions().temperature;
    return (vTempF*(9.0/5)+32.5).format("%d")+"°".toString();

    hidden function valTempF() {
    if (Weather.getCurrentConditions() != null) {
    if Weather.getCurrentConditions().temperature!=null {
    var vTempF = Weather.getCurrentConditions().temperature;
    return (vTempF*(9.0/5)+32.5).format("%d")+"°".toString();

  • You may want to check temperatureUnits on the device to see if you want to display C or F.

    Sys.getDeviceSettings().temperatureUnits

    I do something like:

    var cc== Weather.getCurrentConditions();

    then use cc instead of calling getCurrentConditions() multiple times

  • Here is where I ended...at least for the moment.

    I do has weather before this function so that has already been done.

    hidden function valTempF() {
    var cc=Weather.getCurrentConditions();
    if (cc!=null&&cc.temperature!=null) {
    return (cc.temperature*(9.0/5)+32.5).format("%d")+"°";
    } else {
    return "";
    }
    }