Commit ba9cbf41 authored by Harald Alvestrand's avatar Harald Alvestrand Committed by Commit Bot

Correct form of error returned for RTCError

Bug: chromium:1030631
Change-Id: Idc0b9fe6d4c4db05741cd477ad25f98f83b554e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2196165Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Commit-Queue: Harald Alvestrand <hta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774551}
parent e16a5c8a
......@@ -8,6 +8,36 @@
namespace blink {
namespace {
String RTCErrorDetailToString(webrtc::RTCErrorDetailType detail) {
switch (detail) {
case webrtc::RTCErrorDetailType::NONE:
// This should not happen, it indicates an error in webrtc
LOG(ERROR) << "RTCError: RTCErrorDetail is NONE";
return "";
case webrtc::RTCErrorDetailType::DATA_CHANNEL_FAILURE:
return "data-channel-failure";
case webrtc::RTCErrorDetailType::DTLS_FAILURE:
return "dtls-failure";
case webrtc::RTCErrorDetailType::FINGERPRINT_FAILURE:
return "fingerprint-failure";
case webrtc::RTCErrorDetailType::SCTP_FAILURE:
return "sctp-failure";
case webrtc::RTCErrorDetailType::SDP_SYNTAX_ERROR:
return "sdp-syntax-error";
case webrtc::RTCErrorDetailType::HARDWARE_ENCODER_NOT_AVAILABLE:
return "hardware-encoder-not-available";
case webrtc::RTCErrorDetailType::HARDWARE_ENCODER_ERROR:
return "hardware-encoder-error";
default:
// Included to ease introduction of new errors at the webrtc layer.
NOTREACHED();
return "";
}
}
} // namespace
// static
RTCError* RTCError::Create(const RTCErrorInit* init, String message) {
return MakeGarbageCollected<RTCError>(init, std::move(message));
......@@ -35,7 +65,7 @@ RTCError::RTCError(const RTCErrorInit* init, String message)
RTCError::RTCError(webrtc::RTCError err)
: DOMException(DOMExceptionCode::kOperationError, err.message()),
error_detail_(webrtc::ToString(err.error_detail())),
error_detail_(RTCErrorDetailToString(err.error_detail())),
sctp_cause_code_(err.sctp_cause_code()
? base::Optional<int32_t>(*err.sctp_cause_code())
: base::nullopt) {}
......
......@@ -66,6 +66,10 @@ for (const options of [{}, {negotiated: true, id: 0}]) {
assert_array_equals(events, ['error', 'close']);
assert_true(error instanceof RTCError);
assert_equals(error.name, 'OperationError');
assert_equals(error.errorDetail, 'sctp-failure');
// Closing a peerconnection causes a DTLS close, but this event has
// no corresponding SCTP cause code.
assert_equals(error.sctpCauseCode, null);
}, `Close peerconnection causes close event and error to be called on ${mode}`);
promise_test(async t => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment