Request for better runtime error messages :-)

Aggh... I just used the better part of my morning to find a problem in a new SimpleDataField.

I kept getting one of the dreadful "Unexpected Type Error" with no extra information. As we don't have any real debugging means (hint, hint), I simply chopped away on the code until it would work again.

My code ended up looking as follows:

using Toybox.WatchUi as Ui;
using Toybox.System as Sys;

class MyDF extends Ui.SimpleDataField {
function initialize() {
Sys.println("Initialized");
}

function compute(info) {
Sys.println("compute");
return ""; //txt;
}



And I still got the message!

When I then compared my code with the code from a completely virgin datafield project, I noticed the label assignment was missing in the constructor... And yes, when added above, the code worked again.
I'm likely not the first to make this simple mistake, and I'm surely not the last to do so...

Which leads my to my request: can we please have some better error messages so it is easier to find the core problems?

In this case the message could have included information about the involved variables and operation/functions, which would have helped a lot...
  • We have fixed the issue where not setting the label causes the "Unexpected Type Error". I've created a ticket to come up with more descriptive error messages. In your case I'm guessing you didn't get a call stack, so we'll need to investigate the places this can happen and improve the messages.