Skip to content

Commit

Permalink
[website] Check if coverage method exists
Browse files Browse the repository at this point in the history
  • Loading branch information
goodmind committed Jul 12, 2019
1 parent 226d397 commit 84fb954
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions website/_assets/js/tryFlow.js.es6.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ function getAnnotations(text, callback, options, editor) {
CodeMirror.signal(editor, 'flowCoverage', coverage);
return coverage.expressions.uncovered_locs
})
.catch(() => []),
.catch(err => {
console.error(err)
return []
}),
flow
.then(flowProxy => flowProxy.checkContent('-', text))
.then(errors => {
Expand Down Expand Up @@ -245,7 +248,10 @@ class AsyncLocalFlow {
}

coverage(filename, body) {
return Promise.resolve(this._flow.coverage(filename, body))
if (this._flow.coverage) {
return Promise.resolve(this._flow.coverage(filename, body))
}
return Promise.reject(Error('coverage method is missing'))
}

dumpTypes(filename, body) {
Expand Down
8 changes: 6 additions & 2 deletions website/_assets/js/tryFlowWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ this.onmessage = function(e) {
return;
case "coverage":
getFlow(data.version).then(function(flow) {
var result = flow.coverage(data.filename, data.body);
postMessage({id: data.id, type: "coverage", result: result});
if (flow.coverage) {
var result = flow.coverage(data.filename, data.body);
postMessage({id: data.id, type: "coverage", result: result});
} else {
postMessage({id: data.id, type: "coverage", err: Error('coverage method is missing')});
}
})["catch"](function (e) {
postMessage({id: data.id, type: "coverage", err: e});
})
Expand Down

0 comments on commit 84fb954

Please sign in to comment.