Skip to content

Commit

Permalink
Merge pull request #4 from kadirahq/allow-handlers-to-throw
Browse files Browse the repository at this point in the history
Take the call to handlers out of try block so they can throw.
  • Loading branch information
Muhammed Thanish authored Oct 20, 2016
2 parents 98fd5b2 + 6f1deb3 commit 08e888b
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 08e888b

Please sign in to comment.