Why are some error messages unhelpful ?


  • TMB

    Sometimes, when I make dumb mistakes, I get error messages that ends like this :

    SyntaxError: Unexpected token )
        at Object.<anonymous>:2:143984
        at Chemistry:52:1
        ...
    

    In this example, what line 52 of "Chemistry" does is importing another module, and the unexpected ) was actually on line 21 of that other module.

    Why do errors sometimes not tell exactly on what line of what module the error happened ? Am I supposed to be able to decrypt that Object.<anonymous> line ?



  • I think this has to do with NodeJS instead of with Screeps server code.

    Without some snippet of the module I'm not sure why it gave the incorrect line number, though.


  • TMB

    Here's what the mistake looked like in this case :

    new Behaviour("RestoreLabs", {
        Update: function(creep){
            if (creep.) // actual error 
            /*...*/
        }
    });
    


  • That looks like an error from the Sim. Something about the Sim really messes up line numbers.



  • the sim butchers stack traces b/c a minified/abridged version of the engine runs in your client on your computer. the way your code gets executed is inside an eval() so between the 2, it mangles the stack traces pretty badly.


  • TMB

    This one did happen in simulation indeed, I'd never noticed whether the same would happen in the world. However I'd rather not abandon the simulation and start making big changes live, that's too risky.



  • @estecka that's why you should use a local server for that.
    It is much more reliable and allows you to test multi room behavior.


  • TMB

    While we're at it, is it possible to enable some of the simulation's handy cheats in a local server's world ?



  • Well you are free to modify any aspects of the engine like lowering the constants so you build faster etc.
    Also there are different tools as mods available, but you have to be aware that those are cmd line based.