Chromium Code Reviews| Index: remoting/protocol/errors.h |
| diff --git a/remoting/protocol/errors.h b/remoting/protocol/errors.h |
| index 7f4daf64031c6b8d4341c24da623b72bef84894a..c72d87b2fbb68fa571e471762bfe35e570eedbb4 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,28 @@ enum ErrorCode { |
| UNKNOWN_ERROR, |
| }; |
| +class Error { |
|
joedow
2015/07/29 17:07:02
Adding a helper method to ConnectionToHost felt fi
tonychun
2015/07/29 18:30:33
Done.
|
| + public: |
| + static const char* ProtocolErrorToFriendlyString(ErrorCode error) { |
| + 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 |