Unhandled exception - I don't know why...

I get an ERA message about an “unhandled exception” crash extremely rarely, but every now and then. I have been using the app myself for a year and have never had this crash. No user has ever contacted me so I could ask what they are doing...

The crash happens with the query “if (gearArt > 0)” where “gearArt” is a number and is read from the settings. Only 0, 1 or 2 may be entered there.

I have now written a few lines of check code to work around the error. The question is: can try/catch handle an “unhandled exception” at all?

Do you have any ideas?
Thanks a lot!


        // following checks due to (extremly rare) crashs reportet by ERA for:  if (gearArt > 0) {  --> unhandled exception
        // gearArt is read from Settings, and can actually only be 0, 1, or 2!
        if ( gearArt == null ) {    
            gearArt = 0;
        }
        gearArt = gearArt.toNumber();
        try {
            if (gearArt > 0) {
                // just try
            }    
        } catch (e) {
            gearArt = 0;
        }
        // End check

        if (gearArt > 0) {          // this line triggers the extremly rare crash (unhandled exception)
            var errFlag = 0;
            if (gearArt == 1) {

  • Unlike getValue(), getProperty() doesn't throw any exceptions.

    In 9 years I've never has an issue with NaN with this code.  Properties can only be certain data types.

    This really started as a way to handle numbers that were seen as strings where using a string where the code expected a number caused problems.

  • you didn't :)

    public function getNumberProperty(propertyKey as String) as Number {
        try {
            var value = Properties.getValue(propertyKey);
            if (value != null) {
                value = value.toNumber();
                if (value != null) {
                    return value;
                }
            }
        } catch (e) {
        }
        return Constants.SETTINGS_DEFAULTS.get(propertyKey);
    }