From 0061b3b997c70dbcf36f872670f95add970eee5c Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 11 Jan 2017 16:50:42 +0100 Subject: [PATCH] log error if ast not found --- src/util/internalCallTree.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/util/internalCallTree.js b/src/util/internalCallTree.js index d6867b2a5b..d6f13466f3 100644 --- a/src/util/internalCallTree.js +++ b/src/util/internalCallTree.js @@ -91,7 +91,7 @@ async function buildTree (tree, step, scopeId) { try { sourceLocation = await extractSourceLocation(tree, step) } catch (e) { - return { outStep: step, error: 'InternalCallTree - Error resolving source location. ' + step + ' ' + e.messager } + return { outStep: step, error: 'InternalCallTree - Error resolving source location. ' + step + ' ' + e.message } } if (!sourceLocation) { return { outStep: step, error: 'InternalCallTree - No source Location. ' + step } @@ -149,11 +149,11 @@ function extractSourceLocation (tree, step) { if (!error) { return resolve(sourceLocation) } else { - return reject('InternalCallTree - Cannot retrieve sourcelocation for step ' + step) + return reject('InternalCallTree - Cannot retrieve sourcelocation for step ' + step + ' ' + error) } }) } else { - return reject('InternalCallTree - Cannot retrieve address for step ' + step) + return reject('InternalCallTree - Cannot retrieve address for step ' + step + ' ' + error) } }) }) @@ -161,10 +161,15 @@ function extractSourceLocation (tree, step) { function resolveVariableDeclaration (tree, step, sourceLocation) { if (!tree.variableDeclarationByFile[sourceLocation.file]) { - tree.variableDeclarationByFile[sourceLocation.file] = extractVariableDeclarations(tree.solidityProxy.ast(sourceLocation), tree.astWalker) + var ast = tree.solidityProxy.ast(sourceLocation) + if (ast) { + tree.variableDeclarationByFile[sourceLocation.file] = extractVariableDeclarations(ast, tree.astWalker) + } else { + console.log('Ast not found for step ' + step + '. file ' + sourceLocation.file) + return null + } } - var variableDeclarations = tree.variableDeclarationByFile[sourceLocation.file] - return variableDeclarations[sourceLocation.start + ':' + sourceLocation.length + ':' + sourceLocation.file] + return tree.variableDeclarationByFile[sourceLocation.file][sourceLocation.start + ':' + sourceLocation.length + ':' + sourceLocation.file] } function extractVariableDeclarations (ast, astWalker) {