0

Need help on 'log is not a function' error

Hello everyone,

While I'm developing the my widget I've got this:
CODE
WE 00:00:21:131: [T:18292] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WE 00:00:21:131: [T:18292] ERROR!ERROR!ERROR!ERROR!ERROR!
WE 00:00:21:131: [T:18292] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WE 00:00:21:131: [T:18292] My Company [my.widget]
WE 00:00:21:131: [T:18292] TypeError: log is not a function (mediaplayer.js: Line 1132)
WE 00:00:21:131: [T:18292] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WE 00:00:21:131: [T:18292] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WE 00:00:21:131: [T:18292] ERROR!ERROR!ERROR!ERROR!ERROR!
WE 00:00:21:131: [T:18292] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WE 00:00:21:131: [T:18292] My Company [my.widget]
WE 00:00:21:132: [T:18292] TypeError: log is not a function (application.js: Line 488)
WE 00:00:21:132: [T:18292] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

My widget does not use ay mediaplayer API, so why there is a error about mediaplayer.js?

Any help would be appreciated!
Tinh

by
2 Replies
  • I've troubleshooted my problem. It's because I used the wrong syntax to create a new KONtx.Class. Basically, I define a class like this:
    CODE
    var ScoreboardContent = new KONtx.Class({
    ClassName: 'ScoreboardContent',
    Extends: KONtx.element.Container,
    config: {
    }
    });

    I created a instance of this class like this:
    CODE
    var scoreboard = ScoreboardContent({
    });


    I changed to this:
    CODE
    var scoreboard = new ScoreboardContent({
    });

    It solved the problem! But I think the framework need to be improved here, because it gave a misleading error message which is hard to track down the real problem.
    0
  • QUOTE (911 @ Apr 23 2011, 06:58 PM) <{POST_SNAPBACK}>
    I've troubleshooted my problem. It's because I used the wrong syntax to create a new KONtx.Class. Basically, I define a class like this:
    CODE
    var ScoreboardContent = new KONtx.Class({
    ClassName: 'ScoreboardContent',
    Extends: KONtx.element.Container,
    config: {
    }
    });

    I created a instance of this class like this:
    CODE
    var scoreboard = ScoreboardContent({
    });


    I changed to this:
    CODE
    var scoreboard = new ScoreboardContent({
    });

    It solved the problem! But I think the framework need to be improved here, because it gave a misleading error message which is hard to track down the real problem.

    I disagree. How is a function supposed to know whether it's supposed to be used as a constructor? If you're getting a type error, clearly you're trying to treat a data type as it's not intended to be treated. That in itself is a good indication as to where to start troubleshooting.

    Your implication of improving the framework would lead to a lot of hand-holding like the following code, which I think is a really bad idea.

    CODE
    function Person(name) {
    if (!(this instanceof arguments.callee)) {
    log("isn't this supposed to be a constructor?");
    log("instantiating it for you...");
    return new arguments.callee(name);
    }
    this.name = name;
    }
    var obj = Person("Ben");
    log(obj.name); //logs "Ben"

    There are many values to using a framework, but I don't believe that one of them is to anticipate all the ways a developer could misuse the language. That's simply impossible.
    0

Recent Posts

in General - Yahoo! TV Widgets