Adding error enum to be used by PeerConnectionInterface methods.
The enum is at about the same level of detail as DOMExceptions, and I
looked through the spec making sure that chromium will be able to perform
the DOMException mapping for each one.
The new enum is called RtcError and is outside the PeerConnectionInterface
scope, because we may want to use this for things not associated with a
PeerConnection in the future.
This CL doesn't yet use the error enum anywhere; that will probably happen
in follow-up CLs for the individual methods.
BUG=webrtc:6855
Review-Url: https://codereview.webrtc.org/2564683002
Cr-Commit-Position: refs/heads/master@{#15526}
diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc
index a47b2f2..e1f19ad 100644
--- a/webrtc/api/peerconnection.cc
+++ b/webrtc/api/peerconnection.cc
@@ -432,6 +432,25 @@
namespace webrtc {
+static const char* const kRtcErrorNames[] = {
+ "NONE",
+ "UNSUPPORTED_PARAMETER",
+ "INVALID_PARAMETER",
+ "INVALID_RANGE",
+ "SYNTAX_ERROR",
+ "INVALID_STATE",
+ "INVALID_MODIFICATION",
+ "NETWORK_ERROR",
+ "INTERNAL_ERROR",
+};
+
+std::ostream& operator<<(std::ostream& stream, RtcError error) {
+ int index = static_cast<int>(error);
+ RTC_CHECK(index < static_cast<int>(sizeof(kRtcErrorNames) /
+ sizeof(kRtcErrorNames[0])));
+ return stream << kRtcErrorNames[index];
+}
+
// Generate a RTCP CNAME when a PeerConnection is created.
std::string GenerateRtcpCname() {
std::string cname;