From fd7b997ecd6917502534646c7603470be0ac5d04 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Fri, 1 May 2015 13:59:52 -0700 Subject: [PATCH] @gkatsev added error logging for bad JSON formatting. closes #2113 --- CHANGELOG.md | 1 + grunt.js | 1 + src/js/player.js | 6 +++++- src/js/tracks/text-track-settings.js | 9 +++++---- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0a1c9950..c51110cc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ CHANGELOG * @dconnolly exported the missing videojs.plugin function ([view](https://github.com/videojs/video.js/pull/2103)) * @mmcc added back the captions settings styles ([view](https://github.com/videojs/video.js/pull/2112)) * @gkatsev updated the component.js styles to match the new style guide ([view](https://github.com/videojs/video.js/pull/2105)) +* @gkatsev added error logging for bad JSON formatting ([view](https://github.com/videojs/video.js/pull/2113)) -------------------- diff --git a/grunt.js b/grunt.js index e0651b491..09bb18dca 100644 --- a/grunt.js +++ b/grunt.js @@ -329,6 +329,7 @@ module.exports = function(grunt) { standalone: 'videojs' }, banner: license, + transform: ['babelify'], plugin: [ [ 'browserify-derequire' ] ] diff --git a/src/js/player.js b/src/js/player.js index 52012cab5..88002d0c0 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -1672,7 +1672,11 @@ class Player extends Component { if (dataSetup !== null){ // Parse options JSON // If empty string, make it a parsable json object. - Lib.obj.merge(tagOptions, safeParseTuple(dataSetup || '{}')[1]); + const [err, data] = safeParseTuple(dataSetup || '{}'); + if (err) { + Lib.log.error(err); + } + Lib.obj.merge(tagOptions, data); } Lib.obj.merge(baseOptions, tagOptions); diff --git a/src/js/tracks/text-track-settings.js b/src/js/tracks/text-track-settings.js index e2cbe26ff..7164d1ae6 100644 --- a/src/js/tracks/text-track-settings.js +++ b/src/js/tracks/text-track-settings.js @@ -104,10 +104,11 @@ class TextTrackSettings extends Component { } restoreSettings() { - let values; - try { - values = safeParseTuple(window.localStorage.getItem('vjs-text-track-settings'))[1]; - } catch (e) {} + let [err, values] = safeParseTuple(window.localStorage.getItem('vjs-text-track-settings')); + + if (err) { + Lib.log.error(err); + } if (values) { this.setValues(values);