Skip to content

Commit c35dee9

Browse files
laurent22AnteWall
authored andcommitted
Throw an error instead of crashing app when video source is empty
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
1 parent 3be65ef commit c35dee9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Video.js

+2
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ export default class Video extends Component {
235235
if (uri && uri.match(/^\//)) {
236236
uri = `file://${uri}`;
237237
}
238+
239+
if (!uri) throw new Error('Trying to load empty source.');
238240

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

0 commit comments

Comments
 (0)