fix(@embark/debugger): Add error handling for missing line

During deploy with a failing transaction, embark was crashing due to the variable `line` being passed in as undefined.

Add better error handling to catch this error and prevent embark from crashing.
This commit is contained in:
emizzle 2019-04-03 12:43:14 +11:00 committed by Iuri Matias
parent f27cde9261
commit 5a502b379a
1 changed files with 3 additions and 3 deletions

View File

@ -75,7 +75,7 @@ class TransactionDebugger {
if (err) { return cb([]); }
for (const variable of Object.keys(globals || {})) {
const value: any = globals[variable];
if (line.indexOf(variable) >= 0) {
if (line && line.indexOf(variable) >= 0) {
foundVars.push({name: variable, value});
}
}
@ -83,7 +83,7 @@ class TransactionDebugger {
for (const variable of Object.keys(knownVars.locals || {})) {
const value: any = knownVars.locals[variable];
const variableName: string = variable.split(" ")[0];
if (line.indexOf(variableName) >= 0) {
if (line && line.indexOf(variableName) >= 0) {
foundVars.push({name: variable, value});
}
}
@ -91,7 +91,7 @@ class TransactionDebugger {
for (const variable of Object.keys(knownVars.contract || {})) {
const value: any = knownVars.contract[variable];
const variableName: string = variable.split(" ")[0];
if (line.indexOf(variableName) >= 0) {
if (line && line.indexOf(variableName) >= 0) {
foundVars.push({name: variable, value});
}
}