StructureLab.runReaction(...) throws exception



  • Today, some of my StuctureLabs threw exceptions upon calling runReaction(). I've not been able to figure out the cause of this, but it seemed to me, that maybe something isn't beeing caught in runReaction() and throws an exception instead of returning an ERR_* constant.

     

    The exception had been thrown at

    TypeError: Cannot read property 'X' of undefined
       at StructureLab.runReaction (/opt/engine/dist/game/structures.js:407:43)


  • I can only guess, that my script accidently puts a catalyzed resource into one of the input labs.

    But you should change the ingredient check from, to handle this, too.

    if (!C.REACTIONS[lab1.mineralType][lab2.mineralType] || this.mineralType && this.mineralType != C.REACTIONS[lab1.mineralType][lab2.mineralType]) {
    return C.ERR_INVALID_ARGS;
    }

    to

    if (!C.REACTIONS[lab1.mineralType] || !C.REACTIONS[lab1.mineralType][lab2.mineralType] || this.mineralType && this.mineralType != C.REACTIONS[lab1.mineralType][lab2.mineralType]) {
    return C.ERR_INVALID_ARGS;
    }