Skip to content

Commit

Permalink
1,Improve customer friendliness; 2, fixed typo error (#1980)
Browse files Browse the repository at this point in the history
  • Loading branch information
bright-starry-sky authored Mar 26, 2020
1 parent f114b21 commit f940ddb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/common/base/Status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t>(code()));
str = tmp;
Expand Down
2 changes: 1 addition & 1 deletion src/interface/meta.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/meta/client/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32_t>(resp.get_code()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/usersMan/AuthenticationProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void RevokeProcessor::process(const cpp2::RevokeRoleReq& req) {
auto val = result.value();
const auto role = *reinterpret_cast<const nebula::cpp2::RoleType *>(val.c_str());
if (role != roleItem.get_role_type()) {
handleErrorCode(cpp2::ErrorCode::E_INPROPER_ROLE);
handleErrorCode(cpp2::ErrorCode::E_IMPROPER_ROLE);
onFinished();
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/meta/test/AuthProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
{
Expand All @@ -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
{
Expand Down

0 comments on commit f940ddb

Please sign in to comment.