Skip to content

Commit

Permalink
Throw an error instead of crashing app when video source is empty
Browse files Browse the repository at this point in the history
If an undefined source is accidentally loaded in react-native-video a fatal error SIGABRT will happen and crash the application. This is very difficult to debug since there's apparently no relation between this crash and react-native-video. So this change checks if the URI is empty and, if it is, it throws an error, allowing the user to find out early about the issue.

https://cloud.githubusercontent.com/assets/5795227/20283860/08223ba6-aabb-11e6-9fdc-d12d32b3aa9a.png
  • Loading branch information
laurent22 authored Feb 11, 2019
1 parent 4424774 commit 891add6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ export default class Video extends Component {
if (uri && uri.match(/^\//)) {
uri = `file://${uri}`;
}

if (!uri) throw new Error('Trying to load empty source.');

const isNetwork = !!(uri && uri.match(/^https?:/));
const isAsset = !!(uri && uri.match(/^(assets-library|ipod-library|file|content|ms-appx|ms-appdata):/));
Expand Down

0 comments on commit 891add6

Please sign in to comment.