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

[struct_pack][breakchange] use struct_pack::err_code instead of struct_pack::errc as return value #566

Merged
merged 6 commits into from
Jan 17, 2024

Conversation

poor-circle
Copy link
Collaborator

@poor-circle poor-circle commented Jan 15, 2024

Why

Closes #284

Now the return type of error code is a enum class. Which is hard to use when error handling.

struct_pack::errc ec = struct_pack::deserialize_to(...);
if (ec == struct_pack::errc{})
{
   // ok branch
}
else 
{
  // error branch
}

What is changing

The type of error now is changed to struct struct_pack::err_code(contain a value of struct_pack::errc) not the enum class struct_pack::errc.

Now we can simply the error handling.

struct_pack::err_code ec = struct_pack::deserialize_to(...);
if (!ec)
{
   // ok branch
}
else 
{
  // error branch
}

It's easy for user to update, the old error-handling code-style is still work. and we dont remove the enum class struct_pack::err_code. It's easy to convert each other.

Example

See document.

@poor-circle poor-circle merged commit 63bfdbe into alibaba:main Jan 17, 2024
30 checks passed
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.

[struck_pack] use enum and error_code better
1 participant