question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No way to catch errors on instantiation

See original GitHub issue

This was first mentioned in #57, but note that it is a separate issue hence the new ticket.

When instantiating a player with new Vimeo.Player() with a URL that triggers a 404 (not found) or 403 (privacy settings) error, there is no way to catch this error.

Expected Behavior

player = new Vimeo.Player( ... ) // with private video ID
player.on( 'error', ... )

Error handler is called.

Actual Behavior

Error handler is not called.

Steps to Reproduce

See above


This makes for pretty terrible UX when the player is embedded in a webapp. The user gets no visual feedback from the player; it just doesn’t load. And since no error handler is called it’s also impossible to give feedback via the app interface about it.

The only way is around it is to use loadVideo, which does give you a way to intercept errors (although this doesn’t work sometimes either, that’s what #57 is about). The problem here is, there is no way to create a player without first setting a video url and therefore loading it, as the player on instantiation checks the iframe for a valid source and blows up if it doesn’t find one. So we have to do a workaround of initially set a url to a small dummy video to get the player instantiated, and then call loadVideo to load the actual video and check for errors.

Please give us some way to catch errors during instantiation. 🙏

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:31 (13 by maintainers)

github_iconTop GitHub Comments

4reactions
tenacexcommented, Jun 13, 2018

Hey guys, the fix is out in: https://github.com/vimeo/player.js/releases/tag/v2.6.2

Sorry for the delay. If you have any questions, please don’t hesitate to reach out!

4reactions
rijkcommented, Oct 2, 2017

That works, awesome! Even though I had to change it slightly to:

player = new Vimeo.Player( ... )
player.ready().catch(...)

Otherwise the player variable would not be a reference to the actual player in case of a successful instantiation.

Unfortunately, the error you receive here does not contain any status codes, the only thing you have is the message, which is variable as well (“https://vimeo.com/...” is not embeddable.). So you’d be stuck having to do a regex check on the error message (and pray they never change it) facepalm

What I do now is ‘simply’ call the API myself, and check the HTTP status code of the return.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Resolve the Instantiation Exception in Java - Rollbar
The InstantiationException in Java is thrown when the JVM cannot instantiate a Java type at runtime using the Class.newInstance() method.
Read more >
How to handle exceptions that occur when instantiating a ...
(1) Let the constructor throw an exception. Either rethrow the same exception after logging, or throw a different exception. If the exception it ......
Read more >
How to handle errors in constructors without exceptions?
Basically, there are two steps: First, allocate raw memory for the object. Second, call the constructor in that memory, creating the object. If ......
Read more >
8. Errors and Exceptions — Python 3.11.1 documentation
Errors detected during execution are called exceptions and are not unconditionally fatal: you will soon learn how to handle them in Python programs....
Read more >
Error() constructor - JavaScript - MDN Web Docs
A value indicating the specific cause of the error, reflected in the cause property. When catching and re-throwing an error with a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found