Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(917)

Side by Side Diff: webrtc/api/rtcerror.cc

Issue 2675173003: Adding "adapter" ORTC objects on top of ChannelManager/BaseChannel/etc. (Closed)
Patch Set: Some comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/api/rtcerror.h"
12
13 #include "webrtc/base/arraysize.h"
14
15 namespace {
16
17 static const char* const kRTCErrorTypeNames[] = {
18 "NONE",
19 "UNSUPPORTED_OPERATION",
20 "UNSUPPORTED_PARAMETER",
21 "INVALID_PARAMETER",
22 "INVALID_RANGE",
23 "SYNTAX_ERROR",
24 "INVALID_STATE",
25 "INVALID_MODIFICATION",
26 "NETWORK_ERROR",
27 "RESOURCE_EXHAUSTED",
28 "INTERNAL_ERROR",
29 };
30 static_assert(static_cast<int>(webrtc::RTCErrorType::INTERNAL_ERROR) ==
31 (arraysize(kRTCErrorTypeNames) - 1),
32 "kRTCErrorTypeNames must have as many strings as RTCErrorType "
33 "has values.");
34
35 } // namespace
36
37 namespace webrtc {
38
39 std::ostream& operator<<(std::ostream& stream, RTCErrorType error) {
40 int index = static_cast<int>(error);
41 return stream << kRTCErrorTypeNames[index];
42 }
43
44 webrtc::RTCError CreateAndLogError(webrtc::RTCErrorType type,
45 const std::string& message,
46 rtc::LoggingSeverity severity) {
47 // "No error" shouldn't be logged as an error.
48 RTC_DCHECK(type != RTCErrorType::NONE);
49 rtc::LogMessage(__FILE__, __LINE__, severity).stream() << message << " ("
50 << type << ")";
51 return webrtc::RTCError(type, message);
52 }
53
54 webrtc::RTCError CreateAndLogError(webrtc::RTCErrorType type,
55 const std::string& message) {
56 return CreateAndLogError(type, message, rtc::LS_ERROR);
57 }
pthatcher1 2017/02/10 22:36:52 RTCError is nice enough, and big enough, that it m
Taylor Brandstetter 2017/02/14 06:55:04 Done.
58
59 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698