Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement][C++] Refine the error message of errors of C++ SDK #192

Merged
merged 11 commits into from
Jun 28, 2023

Conversation

acezen
Copy link
Contributor

@acezen acezen commented Jun 25, 2023

Proposed changes

This change aims to refine the error constructor and fulfill the error message detail for C++ SDK.

  • Refine the error constructor with parameter pack, so developers can construct the error by only passing the messages to constructor, no need to concatenate as a string.
  • Fulfill the detail message of error in C++ SDK to let user/developer know what the error is about and why it turn out.

Types of changes

What types of changes does your code introduce to GraphAr?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Related issue: #140

@github-actions
Copy link

github-actions bot commented Jun 25, 2023

🎊 PR Preview eeca88e has been successfully built and deployed to https://alibaba-graphar-build-pr-192.surge.sh

🤖 By surge-preview

@acezen acezen requested a review from lixueclaire June 26, 2023 01:51
@acezen
Copy link
Contributor Author

acezen commented Jun 26, 2023

@lixueclaire The error messages maybe not very correct for writer and builder , or collections(just base on my understanding), can you take a look to the fulfill and if it's not correct, any improvement is good, thanks a lot.

@lixueclaire
Copy link
Contributor

@lixueclaire The error messages maybe not very correct for writer and builder , or collections(just base on my understanding), can you take a look to the fulfill and if it's not correct, any improvement is good, thanks a lot.

Sure, I'll have a look soon. Thank you for making this change.

@@ -69,9 +91,6 @@ enum class StatusCode : unsigned char {
kKeyError,
kTypeError,
kInvalid,
kInvalidValue,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add some comments for the enum class to briefly introduce the types of different status code?

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -851,8 +881,8 @@ class EdgeInfo {
const PropertyGroup& property_group, AdjListType adj_list_type,
IdType vertex_chunk_index, IdType edge_chunk_index) const {
if (!ContainPropertyGroup(property_group, adj_list_type)) {
return Status::KeyError(
"The edge info does not contain the property group.");
return Status::KeyError("The property group: ", property_group,
Copy link
Contributor

Choose a reason for hiding this comment

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

Add "." in the end. The same for the following changes.

@@ -84,7 +84,9 @@ class VertexPropertyArrowChunkReader {
chunk_table_.reset();
}
if (chunk_index_ >= chunk_num_) {
return Status::KeyError();
Copy link
Contributor

Choose a reason for hiding this comment

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

For me, it is a little confused to decide when to use KeyError, and when to use Invalid

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think, KeyError should use in the scenario that user give a key, we can't find a key in our structure like that, otherwise, use a Invalid, so here raise Invalid is better. Thanks for question, I will fix it

Copy link
Contributor

Choose a reason for hiding this comment

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

I think, KeyError should use in the scenario that user give a key, we can't find a key in our structure like that, otherwise, use a Invalid, so here raise Invalid is better. Thanks for question, I will fix it

Then, it is not very clear that which can be called as a "Key": internal vertex id? chunk index? property name? property group? vertex/edge label? adj_list type? ....

@@ -348,7 +359,10 @@ class AdjListOffsetArrowChunkReader {
chunk_table_.reset();
}
if (chunk_index_ >= vertex_chunk_num_) {
return Status::KeyError();
return Status::KeyError("Internal vertex id ", id,
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure that why not to use OutofRange here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, as above mention, I think I confused the KeyError and OutOfRange here, in the seek scenario, the given parameter is in a range and it should raise a OutOfRange here. I will double check all the seek operation.

@@ -108,7 +108,7 @@ Status VertexInfo::Save(const std::string& path) const {

Result<EdgeInfo> EdgeInfo::Load(std::shared_ptr<Yaml> yaml) {
if (yaml == nullptr) {
return Status::YamlError("yaml is nullptr");
return Status::Invalid("yaml is nullptr");
Copy link
Contributor

Choose a reason for hiding this comment

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

modify the message to "yaml shared pointer is nullptr" to be consistent

field = schema->field(index);
if (field->type()->id() != arrow::Type::INT64) {
return Status::TypeError(
"the data type for destination column should be INT64, but got " +
"The data type for destination column should be INT64, but got ",
Copy link
Contributor

Choose a reason for hiding this comment

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

add "index" before "column" to be consistent

return Status::InvalidOperation("the offset column is not provided");
if (index == -1) {
return Status::Invalid("The offset column ", GeneralParams::kOffsetCol,
" is not exist in the input table");
Copy link
Contributor

Choose a reason for hiding this comment

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

does not exist

if (index == -1) {
return Status::Invalid("The source index column ",
GeneralParams::kSrcIndexCol,
" is not exist in the input table");
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

if (index == -1) {
return Status::Invalid("The destination index column ",
GeneralParams::kDstIndexCol,
" is not exist in the input table");
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

return Status::Invalid("Property ", property.name, " of property group ",
property_group, " of edge ",
edge_info_.GetEdgeLabel(),
" is not exist in the input table.");
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Signed-off-by: acezen <qiaozi.zwb@alibaba-inc.com>
Signed-off-by: acezen <qiaozi.zwb@alibaba-inc.com>
Signed-off-by: acezen <qiaozi.zwb@alibaba-inc.com>
@acezen acezen force-pushed the 140-improve-error-message branch from 6d9e435 to 29cef4f Compare June 28, 2023 06:27
if (index == -1) {
return Status::Invalid("The source index column ",
GeneralParams::kSrcIndexCol,
" is not exist in the input table");
Copy link
Contributor

Choose a reason for hiding this comment

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

does not

if (index == -1) {
return Status::Invalid("The destination index column ",
GeneralParams::kDstIndexCol,
" is not exist in the input table");
Copy link
Contributor

Choose a reason for hiding this comment

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

does not

" vertex info.");
}
if (chunk_index < 0) {
return Status::Invalid("The chunk index is negative.");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think IndexError is more suitable here.

Copy link
Contributor

Choose a reason for hiding this comment

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

And the unit test need to be updated too.

@acezen acezen merged commit e92575e into apache:main Jun 28, 2023
@acezen acezen deleted the 140-improve-error-message branch June 28, 2023 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants