From 5ea84f979fef9239ef9757b87ac3147b9a52806a Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 14 Dec 2016 14:15:01 +0100 Subject: [PATCH] warn if compilation result not provided --- src/solidity/localDecoder.js | 3 +++ src/util/internalCallTree.js | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/solidity/localDecoder.js b/src/solidity/localDecoder.js index 516326df42..6d91d1f9ca 100644 --- a/src/solidity/localDecoder.js +++ b/src/solidity/localDecoder.js @@ -2,6 +2,9 @@ function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory) { var scope = internalTreeCall.findScope(vmtraceIndex) + if (!scope) { + return { 'error': 'Can\'t display locals. reason: compilation result might not have been provided' } + } var locals = {} for (var local in scope.locals) { let variable = scope.locals[local] diff --git a/src/util/internalCallTree.js b/src/util/internalCallTree.js index ba0b3817d7..d238308306 100644 --- a/src/util/internalCallTree.js +++ b/src/util/internalCallTree.js @@ -20,7 +20,11 @@ class InternalCallTree { } buildTree (trace) { - buildTree(this, 0, '', trace) + if (!this.solidityProxy.loaded()) { + console.log('compilation result not loaded. Cannot build internal call tree') + } else { + buildTree(this, 0, '', trace) + } } reset () { @@ -31,7 +35,11 @@ class InternalCallTree { } findScope (vmtraceIndex) { - var scopeId = util.findLowerBoundValue(vmtraceIndex, Object.keys(this.scopeStarts)) + var scopes = Object.keys(this.scopeStarts) + if (!scopes.length) { + return null + } + var scopeId = util.findLowerBoundValue(vmtraceIndex, scopes) scopeId = this.scopeStarts[scopeId] var scope = this.scopes[scopeId] var reg = /(.\d|\d)$/