5662e402 by Gary Katsevman

Merge pull request #166 from videojs/responsetext-errors

return responseText in errors
2 parents 079d7092 394b14b2
......@@ -65,6 +65,7 @@
loader.error = {
status: xhr.status,
message: 'HLS playlist request error at URL: ' + url,
responseText: xhr.responseText,
code: (xhr.status >= 500) ? 4 : 2
};
return loader.trigger('error');
......@@ -226,6 +227,7 @@
loader.error = {
status: this.status,
message: 'HLS playlist request error at URL: ' + srcUrl,
responseText: this.responseText,
code: 2 // MEDIA_ERR_NETWORK
};
return loader.trigger('error');
......
......@@ -240,6 +240,7 @@
test('emits an error if a media refresh fails', function() {
var
errors = 0,
errorResponseText = 'custom error message',
loader = new videojs.Hls.PlaylistLoader('live.m3u8');
loader.on('error', function() {
......@@ -251,10 +252,11 @@
'#EXTINF:10,\n' +
'0.ts\n');
clock.tick(10 * 1000); // trigger a refresh
requests.pop().respond(500);
requests.pop().respond(500, null, errorResponseText);
strictEqual(errors, 1, 'emitted an error');
strictEqual(loader.error.status, 500, 'captured the status code');
strictEqual(loader.error.responseText, errorResponseText, 'captured the responseText');
});
test('switches media playlists when requested', function() {
......