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