From 1f16e6805a7ce6a20c33aad7927597add0b3e703 Mon Sep 17 00:00:00 2001 From: bright-starry-sky Date: Thu, 26 Mar 2020 14:55:02 +0800 Subject: [PATCH] 1,Improve customer friendliness; 2, fixed typo error --- src/common/base/Status.cpp | 3 +++ src/interface/meta.thrift | 2 +- src/meta/client/MetaClient.cpp | 4 ++++ src/meta/processors/usersMan/AuthenticationProcessor.cpp | 2 +- src/meta/test/AuthProcessorTest.cpp | 4 ++-- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/common/base/Status.cpp b/src/common/base/Status.cpp index c8e7df6c2f9..65dc7b51cdd 100644 --- a/src/common/base/Status.cpp +++ b/src/common/base/Status.cpp @@ -36,6 +36,9 @@ std::string Status::toString() const { case kPermissionError: str = "PermissionError: "; break; + case kSpaceNotFound: + str = "Space not found"; + break; default: snprintf(tmp, sizeof(tmp), "Unknown error(%hu): ", static_cast(code())); str = tmp; diff --git a/src/interface/meta.thrift b/src/interface/meta.thrift index 67ba0864710..9961a46a087 100644 --- a/src/interface/meta.thrift +++ b/src/interface/meta.thrift @@ -43,7 +43,7 @@ enum ErrorCode { // Authentication Failure E_INVALID_PASSWORD = -41, - E_INPROPER_ROLE = -42, + E_IMPROPER_ROLE = -42, E_INVALID_PARTITION_NUM = -43, E_INVALID_REPLICA_FACTOR = -44, E_INVALID_CHARSET = -45, diff --git a/src/meta/client/MetaClient.cpp b/src/meta/client/MetaClient.cpp index 2585f244536..f2d8b7f0534 100644 --- a/src/meta/client/MetaClient.cpp +++ b/src/meta/client/MetaClient.cpp @@ -559,6 +559,10 @@ Status MetaClient::handleResponse(const RESP& resp) { return Status::Error("No valid collate"); case cpp2::ErrorCode::E_CHARSET_COLLATE_NOT_MATCH: return Status::Error("Charset and collate not match"); + case cpp2::ErrorCode::E_INVALID_PASSWORD: + return Status::Error("Invalid password"); + case cpp2::ErrorCode::E_IMPROPER_ROLE: + return Status::Error("Improper role"); default: return Status::Error("Unknown code %d", static_cast(resp.get_code())); } diff --git a/src/meta/processors/usersMan/AuthenticationProcessor.cpp b/src/meta/processors/usersMan/AuthenticationProcessor.cpp index 33815ed7406..d02ac67bfaf 100644 --- a/src/meta/processors/usersMan/AuthenticationProcessor.cpp +++ b/src/meta/processors/usersMan/AuthenticationProcessor.cpp @@ -136,7 +136,7 @@ void RevokeProcessor::process(const cpp2::RevokeRoleReq& req) { auto val = result.value(); const auto role = *reinterpret_cast(val.c_str()); if (role != roleItem.get_role_type()) { - handleErrorCode(cpp2::ErrorCode::E_INPROPER_ROLE); + handleErrorCode(cpp2::ErrorCode::E_IMPROPER_ROLE); onFinished(); return; } diff --git a/src/meta/test/AuthProcessorTest.cpp b/src/meta/test/AuthProcessorTest.cpp index 1bb75cde76e..75abca1fe17 100644 --- a/src/meta/test/AuthProcessorTest.cpp +++ b/src/meta/test/AuthProcessorTest.cpp @@ -385,7 +385,7 @@ TEST(AuthProcessorTest, GrantRevokeTest) { auto f = processor->getFuture(); processor->process(req); auto resp = std::move(f).get(); - ASSERT_EQ(cpp2::ErrorCode::E_INPROPER_ROLE, resp.get_code()); + ASSERT_EQ(cpp2::ErrorCode::E_IMPROPER_ROLE, resp.get_code()); } // actual role is GUEST, but revoke unknown, expect error. { @@ -398,7 +398,7 @@ TEST(AuthProcessorTest, GrantRevokeTest) { auto f = processor->getFuture(); processor->process(req); auto resp = std::move(f).get(); - ASSERT_EQ(cpp2::ErrorCode::E_INPROPER_ROLE, resp.get_code()); + ASSERT_EQ(cpp2::ErrorCode::E_IMPROPER_ROLE, resp.get_code()); } // revoke {