diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js
index 6b607c4d1c..81bb8fafe2 100644
--- a/lib/media/media_source_engine.js
+++ b/lib/media/media_source_engine.js
@@ -1265,7 +1265,8 @@ shaka.media.MediaSourceEngine = class {
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,
- exception);
+ exception,
+ this.video_.error || 'No error in the media element');
} finally {
// Unblock the queues.
for (const contentType in this.sourceBuffers_) {
@@ -1308,7 +1309,8 @@ shaka.media.MediaSourceEngine = class {
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,
- exception));
+ exception,
+ this.video_.error || 'No error in the media element'));
}
this.popFromQueue_(contentType);
}
diff --git a/lib/util/error.js b/lib/util/error.js
index 243f5ab156..a544689b59 100644
--- a/lib/util/error.js
+++ b/lib/util/error.js
@@ -462,6 +462,7 @@ shaka.util.Error.Code = {
/**
* A MediaSource operation threw an exception.
*
error.data[0] is the exception that was thrown.
+ *
error.data[1] is the error object from the video element.
*/
'MEDIA_SOURCE_OPERATION_THREW': 3015,
diff --git a/test/media/media_source_engine_unit.js b/test/media/media_source_engine_unit.js
index 3082cd5370..4806977212 100644
--- a/test/media/media_source_engine_unit.js
+++ b/test/media/media_source_engine_unit.js
@@ -374,12 +374,13 @@ describe('MediaSourceEngine', () => {
it('rejects promise when operation throws', async () => {
audioSourceBuffer.appendBuffer.and.throwError('fail!');
- mockVideo.error = {code: 5};
+ mockVideo.error = {code: 5, message: 'something failed'};
const expected = Util.jasmineError(new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,
- jasmine.objectContaining({message: 'fail!'})));
+ jasmine.objectContaining({message: 'fail!'}),
+ {code: 5, message: 'something failed'}));
await expectAsync(
mediaSourceEngine.appendBuffer(
ContentType.AUDIO, buffer, null,
@@ -712,7 +713,8 @@ describe('MediaSourceEngine', () => {
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,
- jasmine.objectContaining({message: 'fail!'})));
+ jasmine.objectContaining({message: 'fail!'}),
+ {code: 5}));
await expectAsync(mediaSourceEngine.remove(ContentType.AUDIO, 1, 5))
.toBeRejectedWith(expected);
expect(audioSourceBuffer.remove).toHaveBeenCalledWith(1, 5);