You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #include "api/rtc_error.h"
  11. #include "rtc_base/arraysize.h"
  12. namespace {
  13. const char* kRTCErrorTypeNames[] = {
  14. "NONE",
  15. "UNSUPPORTED_OPERATION",
  16. "UNSUPPORTED_PARAMETER",
  17. "INVALID_PARAMETER",
  18. "INVALID_RANGE",
  19. "SYNTAX_ERROR",
  20. "INVALID_STATE",
  21. "INVALID_MODIFICATION",
  22. "NETWORK_ERROR",
  23. "RESOURCE_EXHAUSTED",
  24. "INTERNAL_ERROR",
  25. };
  26. static_assert(static_cast<int>(webrtc::RTCErrorType::INTERNAL_ERROR) ==
  27. (arraysize(kRTCErrorTypeNames) - 1),
  28. "kRTCErrorTypeNames must have as many strings as RTCErrorType "
  29. "has values.");
  30. } // namespace
  31. namespace webrtc {
  32. RTCError::RTCError(RTCError&& other) = default;
  33. RTCError& RTCError::operator=(RTCError&& other) = default;
  34. // static
  35. RTCError RTCError::OK() {
  36. return RTCError();
  37. }
  38. const char* RTCError::message() const {
  39. return message_.c_str();
  40. }
  41. void RTCError::set_message(std::string message) {
  42. message_ = std::move(message);
  43. }
  44. const char* ToString(RTCErrorType error) {
  45. int index = static_cast<int>(error);
  46. return kRTCErrorTypeNames[index];
  47. }
  48. } // namespace webrtc