Skip to content
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #85 from Financial-Times/log-errors-to-sentry
Browse files Browse the repository at this point in the history
Report Ad loading errors via o-errors event
  • Loading branch information
commuterjoy authored Jan 25, 2017
2 parents eda69c9 + 5b460a7 commit 3b25170
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/js/ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class VideoAds {
});

googleSdkScript.addEventListener('error', (e) => {
this.reportError(e);
reject(e);
});
}
Expand Down Expand Up @@ -208,6 +209,7 @@ class VideoAds {
this.adsManager.start();
} catch (adError) {
// An error may be thrown if there was a problem with the VAST response.
this.reportError(adError);
this.video.videoEl.play();
}
}
Expand Down Expand Up @@ -319,7 +321,16 @@ class VideoAds {
}
}

adErrorHandler() {
reportError(error) {
document.body.dispatchEvent(new CustomEvent('oErrors.log', { bubbles: true, detail: { error: error } }));
}

adErrorHandler(adError) {

// convert the Google Ad error to a JS one
const message = `${adError.getErrorCode()}, ${adError.getType()}, ${adError.getMessage()}, ${adError.getVastErrorCode()}`;
this.reportError(new Error(message));

this.adsManager && this.adsManager.destroy();
this.video.containerEl.removeChild(this.adContainerEl);
if (this.overlayEl) {
Expand Down

0 comments on commit 3b25170

Please sign in to comment.