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

feat: Panic -> Error migration #555

Merged
merged 3 commits into from
Jun 5, 2024

Conversation

SoulPancake
Copy link
Contributor

This is to address #366

This is in draft state with some idea I understood from the current proposal thread.
We can discuss and decide on what specifically we want to do here, and how much of it has to stay backwards compatible and in what all way and whether we want to introduce some breaking major changes too.

@rueian Let's continue the discussion further on this

message.go Outdated
var defaultErrorStrMapSlice = make([]map[string]string, 0)
var defaultErrorIntMap = make(map[string]int64)
var defaultErrorKeyValues = KeyValues{}
var defaultErrorKeyZScores = KeyZScores{}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

On retrospect this might not be a great idea at all

Maybe I misunderstood the proposal a little

Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need to pre-define these default error values. We should just return a zero value of the corresponding type as well as the error. For example:

return defaultErrorRedisMessageSlice, fmt.Errorf("redis message type %s is not a array", typeNames[typ])

should be just

return nil, fmt.Errorf("redis message type %s is not a array", typeNames[typ])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rueian Zero values for the non-nullable ones?

It will not compile in those cases when we send back a nil for non-nullable one I guess
Okay let me do try this refactor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, is this the only file where we require changes for this? @rueian

Any other changes we require other than the tests

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, the message.go is the only file that needs to be changed other than the tests.

@SoulPancake SoulPancake marked this pull request as ready for review June 4, 2024 14:46
@SoulPancake SoulPancake requested a review from rueian June 4, 2024 14:46
@SoulPancake SoulPancake requested a review from rueian June 4, 2024 15:38
Copy link
Collaborator

@rueian rueian left a comment

Choose a reason for hiding this comment

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

Cool! LGTM! Thank you @SoulPancake!

@rueian rueian merged commit 6af9676 into redis:main Jun 5, 2024
12 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.

2 participants