ERA reports some cases of unhandled exception from Application.Properties.getValue() in onLayout()

I'm getting some ERA reports of an unhandled exception when calling Application.Properties.getValue() from onLayout() - but I've no idea why it could be happening ...

It is happening in both an app and a watchface - and it's always on the very first call to access the properties after starting up.

The property is defined in the properties.xml just like normal:

    <property id="pg" type="boolean">false</property>  <!-- position got -->

And is accessed just with a normal call:

    var v = Application.Properties.getValue("pg");

It clearly works for most people using the app, but why are there some instances of exceptions being created?

The documentation says these are the possible exceptions:

  • (Toybox::Lang::UnexpectedTypeException)

    Thrown if key is of type null, Array, or Dictionary

    (Toybox::Application::Properties::InvalidKeyException)

    Thrown if key does not exist in Application Settings

Is there some other exception possible here?

Any suggestions for how I could debug this?

  • It's indeed a property with no settings. I'm using them to define devices that are OLED, or has no floors, or if they are square or round,... So I define those properties based on jungle files etc. Using a try/ catch is an option, but then it results in other errors are weird layouts because I actually need the correct device information.

    Is there a better way for doing this?

    If I understand correctly, properties should only be used for actual settings?

  • Just to show you an alternative way to handle device specific source code and definitions:

    What I do to define device specific constant data is following:

    fenix7x.sourcePath = $(srcBase);../../shared/src-devices/fenix7x
    fenix7x.resourcePath=$(resBase)
    fenix6xpro.sourcePath = $(srcBase);../../shared/src-devices/fenix6xpro
    fenix6xpro.resourcePath=$(resBase)
    enduro.sourcePath = $(srcBase);../../shared/src-devices/enduro
    enduro.resourcePath=$(resBase)
    
    // ...

    And then I have a DeviceInfo.mc file for each device like e.g. following:

    class DeviceInfo {
    
        static const MODEL = 10 /* fenix6xpro */;
        static const DEVICE_NAME = "Fenix 6X";
        static const SIZE = [280, 280];
        static const HEIGHT_FONT_OVERLAY = 8;
    
        static const SUPPORTS_PARTIAL = true;
    	static const HIGH_MEMORY = false;
    	
    	// ...
    }

  • Well that's a very good alternative. I honestly did not now about the option for sourcepath. Very interesting!