Complete
over 4 years ago

Not a bug.

Weather.getCurrentConditions().attribute crashes when data is not available SDK 3.2.1

I am using the brand new shiny SDK 3.2.1 weather feature which I absolutely love. However, I was dismayed when my watch face crashed in the simulator after I unchecked the "Weather Data Available" box in the settings. I was calling Weather.getCurrentConditions().temperature, and I got an unexpected type value error. When I called Weather.getCurrentConditions() instead, it recognized it as a null value and I could use an if statement to work around it. I have not tested the other weather functions or attributes.

Can the attributes for the weather functions get null values when data is not available? Thanks

Former Member
Former Member
Parents
  • Just a general comment, but some of the stuff you're doing each time the function is called can just be done once when the app starts. No need to do the loadResource each time for example.  That's something that hits the file system, so can be expensive.

Comment
  • Just a general comment, but some of the stuff you're doing each time the function is called can just be done once when the app starts. No need to do the loadResource each time for example.  That's something that hits the file system, so can be expensive.

Children
  • Former Member
    Former Member over 4 years ago in reply to jim_m_58

    Hi Jim,

    Thanks for the tip. I have this function in a separate Util.mc file, but in this case the strings are so simple I can just use "C" and "F" instead of calling resources.

    Since temperature is the only thing I need, at first I did not even think about using the broader function Weather.getCurrentConditions() by itself. But after reading the API and seeing that it should return null, I decided to try it.

    This is the error I get in the console:

    Error: Unexpected Type Error
    Details: Failed invoking <symbol>
    Stack:
    - getTemperature() at C:\...\source\Util.mc:211 0x1000071d

    - ...

    - ...

    After I this code: 

    The line reference is the same line as the if statement.