Started error handling
This commit is contained in:
		@@ -9,15 +9,15 @@ module.exports =  {
 | 
			
		||||
    },
 | 
			
		||||
    a: {
 | 
			
		||||
      name: "a",
 | 
			
		||||
      type: "text",
 | 
			
		||||
      type: "number",
 | 
			
		||||
      required: true,
 | 
			
		||||
      inline: false
 | 
			
		||||
      inline: true
 | 
			
		||||
    },
 | 
			
		||||
    b: {
 | 
			
		||||
      name: "b",
 | 
			
		||||
      type: "text",
 | 
			
		||||
      type: "number",
 | 
			
		||||
      required: true,
 | 
			
		||||
      inline: false
 | 
			
		||||
      inline: true
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  output: true,
 | 
			
		||||
@@ -33,7 +33,7 @@ module.exports =  {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(!require("./util/coPrime.js")(a, 26)){
 | 
			
		||||
      console.log(a, 26, "not coprime");
 | 
			
		||||
      throw "a and 26 must be coprime";
 | 
			
		||||
      return "";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,9 @@ var events = require("./events.js");
 | 
			
		||||
var blocks = require("./blocks");
 | 
			
		||||
 | 
			
		||||
function resolveOutput(block, cache){
 | 
			
		||||
  try{
 | 
			
		||||
    var inputValues = {};
 | 
			
		||||
    var error = "";
 | 
			
		||||
    for(var input in block.inputs){
 | 
			
		||||
      if(block.inputs[input].joined){ //if it's joined to something else
 | 
			
		||||
        if(block.inputs[input].joined in cache){ //if output of other block is already in cache
 | 
			
		||||
@@ -17,12 +19,19 @@ function resolveOutput(block, cache){
 | 
			
		||||
      else if(block.inputs[input].value){ //if value is already set, just save that
 | 
			
		||||
        inputValues[input] = block.inputs[input].value;
 | 
			
		||||
      }
 | 
			
		||||
      if(blocks[block.type].inputs[input].required && !(inputValues[input])){ //if input is required and is missing
 | 
			
		||||
        throw "A required input is missing";
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var output = blocks[block.type].execute(inputValues, block);
 | 
			
		||||
    cache[block.id] = output;
 | 
			
		||||
 | 
			
		||||
    return output;
 | 
			
		||||
  }
 | 
			
		||||
  catch(err){
 | 
			
		||||
    console.log("ERROR", err);
 | 
			
		||||
    return "";
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function calculateOutputBlocks(){
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user