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: support errors.Is(), errors.As() in RedisError #155

Merged
merged 1 commit into from
Apr 14, 2024

Conversation

Syuparn
Copy link
Contributor

@Syuparn Syuparn commented Apr 8, 2024

By this PR, internal errors wrapped by redsync.RedisError can be checked by errors.Is() and errors.As(). This helps errors handlings to check the error cause like below.

if err := mutex.Lock(); err != nil {
	if errors.Is(err, syscall.ECONNREFUSED) { // connection refused error wraps this
		fmt.Printf("connection refused: %v\n", err)
	}
	fmt.Printf("unexpected: %v\n", err)
	return
}

@hjr265 hjr265 merged commit 6b38f77 into go-redsync:master Apr 14, 2024
@hjr265
Copy link
Member

hjr265 commented Apr 14, 2024

Thank you for this PR, @Syuparn!

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