Cannot catch Permission Required Exception?

Is there a specific exception raised when an Permission Required error occurs?

My watchface uses animate() and although animate() is only being called with onUpdate(), i am sometimes getting errors:

Error: Permission Required
Details: Symbol 'animate' not available to 'Watch Face'
 

I tried wrapping the .animate() calls in `try` and `catch` blocks, but doesn't seem to work; this error is still raised.

Is there a way to safely call .animate() in a watchface such that it only occurs when the face has permissions to call said function?

  • From the API Doc:

    Will cause an app crash if called from background or data field app, or from watch face while in low power mode

    --------------

    You can only use it when the watch face isn't in low power mode - for about 10 seconds after a gesture.

    You can tell what mode you are in with onExitSleep() and onEnterSleep()

  • Yup, I'm using on(Enter|Exit)Sleep and it's working correctly on the simulator. But on device it causes crashes sometimes. Maybe it's a race condition based on at which point in the timing cycle sleep is entered. Entering low power mode occurs more frequently on the device than I have the patience to trigger on the simulator with mouse clicks.  It would be cool to be able to trigger these types of things via a `mokneydo` or `simulator` command so we could set up automated random changes-of-state for the simulator.

    Also, is there a difference between Sleep and Low Power Mode? If they're the same thing, it would be less confusing if only one term was used to describe it.

  • onEnterSleep and onExitSleep are going to low power and leaving low power.  When onEnterSleep is called, make sure you do what's needed to stop the animation immediately.  Maybe just calling WatchUi.requestUpdate based on your code.  Otherwise, the animation could try to continue, which will cause the crash