2017-02-16 23:31:33 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright 2017 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/rtcerror.h"
|
2017-02-16 23:31:33 -08:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/arraysize.h"
|
2017-02-16 23:31:33 -08:00
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
static const char* const kRTCErrorTypeNames[] = {
|
|
|
|
|
"NONE",
|
|
|
|
|
"UNSUPPORTED_OPERATION",
|
|
|
|
|
"UNSUPPORTED_PARAMETER",
|
|
|
|
|
"INVALID_PARAMETER",
|
|
|
|
|
"INVALID_RANGE",
|
|
|
|
|
"SYNTAX_ERROR",
|
|
|
|
|
"INVALID_STATE",
|
|
|
|
|
"INVALID_MODIFICATION",
|
|
|
|
|
"NETWORK_ERROR",
|
|
|
|
|
"RESOURCE_EXHAUSTED",
|
|
|
|
|
"INTERNAL_ERROR",
|
|
|
|
|
};
|
|
|
|
|
static_assert(static_cast<int>(webrtc::RTCErrorType::INTERNAL_ERROR) ==
|
|
|
|
|
(arraysize(kRTCErrorTypeNames) - 1),
|
|
|
|
|
"kRTCErrorTypeNames must have as many strings as RTCErrorType "
|
|
|
|
|
"has values.");
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2018-09-13 10:07:07 +02:00
|
|
|
RTCError::RTCError(RTCError&& other) = default;
|
|
|
|
|
RTCError& RTCError::operator=(RTCError&& other) = default;
|
2017-02-16 23:31:33 -08:00
|
|
|
|
|
|
|
|
// static
|
|
|
|
|
RTCError RTCError::OK() {
|
|
|
|
|
return RTCError();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* RTCError::message() const {
|
2018-09-13 10:07:07 +02:00
|
|
|
return message_.c_str();
|
2017-02-16 23:31:33 -08:00
|
|
|
}
|
|
|
|
|
|
2018-09-13 10:07:07 +02:00
|
|
|
void RTCError::set_message(std::string message) {
|
|
|
|
|
message_ = std::move(message);
|
2017-02-16 23:31:33 -08:00
|
|
|
}
|
|
|
|
|
|
2018-04-03 12:22:07 +02:00
|
|
|
// TODO(jonasolsson): Change to use absl::string_view when it's available.
|
|
|
|
|
std::string ToString(RTCErrorType error) {
|
2017-02-16 23:31:33 -08:00
|
|
|
int index = static_cast<int>(error);
|
2018-04-03 12:22:07 +02:00
|
|
|
return std::string(kRTCErrorTypeNames[index]);
|
2017-02-16 23:31:33 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|