Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throw error when plugin is missing #1931

Closed
wants to merge 3 commits into from
Closed

throw error when plugin is missing #1931

wants to merge 3 commits into from

Conversation

thijstriemstra
Copy link
Contributor

Improve error for missing plugin, refs #1928.

@@ -99,7 +99,11 @@ vjs.Player = vjs.Component.extend({

if (options['plugins']) {
vjs.obj.each(options['plugins'], function(key, val){
this[key](val);
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than using try/catch, we can see whether this[key] is a function and then log an error. This way it continues working even if a plugin is missing but we still have a better error log.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to figure out what the right way to go was here but, in my case, my video.js player is just an empty shell without the plugin and I want to abort further loading. It sounds like logging it would not help me determine if the video.js player (and required plugin) is broken?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe log an error, fire an error event?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thijstriemstra
Copy link
Contributor Author

Could anyone help me figure out why this build is dying?

@heff
Copy link
Member

heff commented Mar 6, 2015

It looks like it doesn't like window.throws
https://travis-ci.org/videojs/video.js/builds/53280031#L466

@gkatsev
Copy link
Member

gkatsev commented Mar 6, 2015

throws needs to be added here https://github.com/videojs/video.js/blob/master/.jshintrc#L14-L45

@gkatsev
Copy link
Member

gkatsev commented Mar 6, 2015

and then you should use throws without referencing it from window.

@thijstriemstra
Copy link
Contributor Author

Ok, thanks I'll check it out asap. I used the window reference because I saw this being used in text track tests, doesn't seem any other tests that check for a throw.

@thijstriemstra
Copy link
Contributor Author

It doesn't fix my local jshint 'issues' though, but I guess that's a different PR.

@thijstriemstra
Copy link
Contributor Author

Adding throws to jshint solved the problem in the jshint build step but not the minify:tests target:

test/unit/plugins.js:168: ERROR - Parse error. identifier is a reserved word
  throws(function() {
  ^

Since I'll just use videojs.log.error, and not be checking for a raised exception, I'm not going to bother looking into that error further.

@thijstriemstra
Copy link
Contributor Author

Why are the tests minified anyway? This causes unexpected results where the key name is minified it seems:

    Expected: nonExistingPlugin
    Actual: Yf
        at /Users/foo/Sites/projects/video.js/node_modules/qunitjs/qunit/qunit.js:1540
        at /Users/foo/Sites/projects/video.js/build/files/test.minified.video.js:344
        at /Users/foo/Sites/projects/video.js/node_modules/qunitjs/qunit/qunit.js:1303
        at /Users/foo/Sites/projects/video.js/node_modules/qunitjs/qunit/qunit.js:1463
        at process (/Users/foo/Sites/projects/video.js/node_modules/qunitjs/qunit/qunit.js:1016)
        at /Users/foo/Sites/projects/video.js/node_modules/qunitjs/qunit/qunit.js:186

I guess making it a string key in the test fixes it.

@thijstriemstra
Copy link
Contributor Author

Updated pull request and now a plugin that does not exist logs an error.

@heff
Copy link
Member

heff commented Mar 30, 2015

We don't need throws in the globals any more. But otherwise looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants