Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

expected support error message #970

Merged
merged 1 commit into from
Jun 29, 2023

Conversation

Presburger
Copy link
Member

@Presburger Presburger commented Jun 28, 2023

issue: #971

@sre-ci-robot sre-ci-robot requested review from foxspy and PwzXxm June 28, 2023 07:45
@sre-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Presburger

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mergify
Copy link

mergify bot commented Jun 28, 2023

@Presburger Please associate the related issue to the body of your Pull Request. (eg. “issue: #”)

@PwzXxm
Copy link
Collaborator

PwzXxm commented Jun 28, 2023

Is it going to be another PR for hooking msg?

@@ -321,6 +347,12 @@ class Config {
} else {
LOG_KNOWHERE_ERROR_ << "Out of range in json: param [" << it.first << "] should be in ["
<< ptr->range.value().first << ", " << ptr->range.value().second << "].";
if (err_msg) {
*err_msg = std::string("param ") + it.first + " out of range " + "[ " +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider creating a temp string for both LOG_KNOWHERE_ERROR_ and assigning to err_msg? may be cleaner if we avoid repeating the formatting code twice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good advice, but the code maybe looks weird.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the below looks slightly better? Unless we have a good reason to have different messages for the logging/exception. Feel free to ignore this comment if you insist.

auto msg = std::string("param ") + it.first + " out of range " + "[ " +
                std::to_string(ptr->range.value().first) + "," +
                std::to_string(ptr->range.value().second) + " ]";
LOG_KNOWHERE_ERROR_ << msg;
if (err_msg) {
    *err_msg = msg;
}

src/common/config.cc Outdated Show resolved Hide resolved
const std::string&
what() const {
return msg;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it would be better if the message is attached to a non success Status instead of an excepted: we may have some error info to be returned even if the current method returns only Status.

But now our Status is an enum class and cannot be extended. Would be a large change if we want to do that.

See absl::Status for reference.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your proposed change to pass err_msg to the returned value of Search the code looks like this, which is pretty clumsy:

expected<DataSetPtr> Search() const {
    auto cfg = this->node->CreateConfig();
    std::string err;
    auto status = LoadConfig(cfg.get(), json, knowhere::SEARCH, "Search", &err);
    if (err != Status::success) {
        expected<DataSetPtr> ret(err);
        ret << err;
        return ret;
    }
    ...
}

Status
LoadConfig(BaseConfig* cfg, const Json& json, knowhere::PARAM_TYPE param_type, const std::string& method, std::string* const err = nullptr) const {
    Json json_(json);
    auto res = Config::FormatAndCheck(*cfg, json_, err);
    LOG_KNOWHERE_DEBUG_ << method << " config dump: " << json_.dump();
    RETURN_IF_ERROR(res);
    return Config::Load(*cfg, json_, param_type, err);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the return status, Leads to huge changes.
err_msg, Compatible with old code.
I think just add err_msg for search api.

@zhengbuqian
Copy link
Collaborator

/lgtm

with a minor comment

@mergify mergify bot added the ci-passed label Jun 29, 2023
@sre-ci-robot sre-ci-robot merged commit e305090 into milvus-io:main Jun 29, 2023
@liliu-z
Copy link
Member

liliu-z commented Jul 11, 2023

issue: milvus-io/milvus#25079

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants