How do you debug "symbol not found"?

Former Member
Former Member
I got stuck with this completely useless error message:

Failed invoking <symbol>
Symbol Not Found Error


That's all there is to it! No stack trace, no symbol name. My code is

Ui.pushView(new Ui.Confirmation("Stop?"), new EndDelegate(), Ui.SLIDE_UP);
...
class EndDelegate extends Ui.BehaviorDelegate {
var app = App.getApp();

function onBack()
{
Sys.println("called Back");
app.switchToView(startView, startDelegate, Ui.SLIDE_UP);
return true;
}

function onNextPage()
{
Sys.println("called onNextPage");
Ui.popView(Ui.SLIDE_UP);
app.currentView.start();
return true;
}
}


I see the confirmation window. The error appears in the console when I press a button. I don't see any of the two printlns being called.
  • When you push a Ui.Confirmation, you need to pass a delegate that inherits from Ui.ConfirmationDelegate.

    It also seems inconsistent that you are using view management functions from different places (popView from Ui, and switchToView from app). It seems that given that the variable currentView is likely to not be updated.
  • Former Member
    Former Member over 10 years ago
    When you push a Ui.Confirmation, you need to pass a delegate that inherits from Ui.ConfirmationDelegate.

    It also seems inconsistent that you are using view management functions from different places (popView from Ui, and switchToView from app). It seems that given that the variable currentView is likely to not be updated.


    Indeed, it was the wrong superclass. Thanks! Still, the original question applies. The error message is not informative, how does one generally approach such errors?

    Indeed I'm pushing the confirmation view on the stack, while my application views are switched. I'm still figuring out what's the best programming style, it's my second day of Monkey C... but it seemed clearer this way (the confirmation window is like a modal dialog in traditional UIs that I can dismiss.. my other views are not user-navigable).
  • This case is a little special because the error occurs in your code, but the fallout happens in the virtual machine code when it tries to call a method that doesn't exist. In these cases you will typically get no information about where the failure occurred. When a file name an line number are given, you don't have to do much. When no information is given, I see two options.

    • Remove/Add code: comment out blocks of code until you the error goes away, then add some of it back. Repeat until you know what the affected line is.
    • Put Sys.println at the top of every single user function. Typically the last bit of code that executes is where the problem is.


    Neither of these options are that good. At one point I went so far as to write a logging facility that allowed me to enable/disable tracing for parts of the code. Something like this in MyApp.onStart() would enable tracing of all debug code (a Sys.println call upon entry) for every method in my Ui.View derived classes), and enable debug messages (any thing I wanted to print that wasn't a function entry).

    Debug.setDebugLevel(Debug.View, Debug.Trace);
    Debug.setDebugLevel(~Debug.View, Debug.Messages);


    Then I had this all over the code...

    class MyView extends Ui.View {

    function initialize() {
    Debug.trace(Debug.View, "MyClass.initialize");
    }

    function onUpdate() {
    Debug.trace(Debug.View, "MyClass.onUpdate");

    if (something) {
    Debug.message(Debug.View, "MyClass.something");
    }
    }
    }


    I used it for a while, but decided that for most projects it was overkill. Especially because each of the strings takes up valuable memory...

    Travis
  • We're working on getting better testing tools in place that should assist with debugging. Sys.println() is a little basic, but it's the best thing that's currently available.
  • Former Member
    Former Member over 10 years ago
    We're working on getting better testing tools in place that should assist with debugging. Sys.println() is a little basic, but it's the best thing that's currently available.


    Thanks for all replies!

    Did you consider open-sourcing some of your development stack? I'm sure there are people who could help. The Eclipse plugin is also quite basic.