Chromium Code Reviews| Index: remoting/protocol/errors.h |
| diff --git a/remoting/protocol/errors.h b/remoting/protocol/errors.h |
| index 7f4daf64031c6b8d4341c24da623b72bef84894a..8b93992a2417bb95c7fcdb6de78e0d842d9cf738 100644 |
| --- a/remoting/protocol/errors.h |
| +++ b/remoting/protocol/errors.h |
| @@ -5,6 +5,12 @@ |
| #ifndef REMOTING_PROTOCOL_ERROR_H_ |
| #define REMOTING_PROTOCOL_ERROR_H_ |
| +#include "base/logging.h" |
| + |
| +#define RETURN_STRING_LITERAL(x) \ |
| +case x: \ |
| +return #x; |
| + |
| namespace remoting { |
| namespace protocol { |
| @@ -25,6 +31,24 @@ enum ErrorCode { |
| UNKNOWN_ERROR, |
| }; |
| +inline const char* ErrorCodeToString(ErrorCode error) { |
|
joedow
2015/07/29 20:09:31
remove inline
|
| + switch (error) { |
| + RETURN_STRING_LITERAL(OK); |
| + RETURN_STRING_LITERAL(PEER_IS_OFFLINE); |
| + RETURN_STRING_LITERAL(SESSION_REJECTED); |
| + RETURN_STRING_LITERAL(INCOMPATIBLE_PROTOCOL); |
| + RETURN_STRING_LITERAL(AUTHENTICATION_FAILED); |
| + RETURN_STRING_LITERAL(CHANNEL_CONNECTION_ERROR); |
| + RETURN_STRING_LITERAL(SIGNALING_ERROR); |
| + RETURN_STRING_LITERAL(SIGNALING_TIMEOUT); |
| + RETURN_STRING_LITERAL(HOST_OVERLOAD); |
| + RETURN_STRING_LITERAL(UNKNOWN_ERROR); |
| + default: |
| + LOG(ERROR) << "Unknown error: '" << error << "'"; |
| + return "UNKNOWN ERROR"; |
| + } |
| +} |
| + |
| } // namespace protocol |
| } // namespace remoting |