Skip to content

Commit

Permalink
Take the call to handlers out of try block so they can throw.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aruna Herath committed Oct 20, 2016
1 parent 98fd5b2 commit 6f1deb3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,18 @@ export class PostmsgTransport {
if(!e.data || typeof(e.data) !== 'string') {
return;
}
let data;
try {
const { key, event } = JSON.parse(e.data);
if (key === this._key) {
this._handler(event);
}
data = JSON.parse(e.data);
} catch (e) {
return null;
}
if(!data || typeof(data) !== 'object') {
return null;
}
const { key, event } = data;
if (key === this._key) {
this._handler(event);
}
}
}

0 comments on commit 6f1deb3

Please sign in to comment.