fix: guard isFailure with nil check to simplify failure conditions#23
Merged
Conversation
… receive nil errors
Nil errors are now always treated as successes before calling the user-provided
failure condition function. This simplifies failure condition implementations
(e.g. IgnoreContextCanceled) by removing the need to handle the nil case.
Also applies minor Go style cleanups: rename sentinel → errSentinel, use `any`
instead of `interface{}`, and remove unnecessary loop variable copies (Go 1.22+).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
marcboeker
approved these changes
Mar 26, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Hoglet’s failure-observation behavior so that nil errors are always treated as successes and user-provided failure condition functions are only evaluated for non-nil errors, along with a few related doc/test cleanups.
Changes:
- Guard
isFailure(err)calls witherr != nilwhen observing outcomes. - Update
WithFailureConditiondocumentation and simplifyIgnoreContextCanceled. - Minor test refactors (rename sentinel error var, use
any, remove range-var copies in tests).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| options.go | Updates failure-condition docs and simplifies IgnoreContextCanceled. |
| hoglet.go | Ensures failure conditions aren’t invoked for nil errors by guarding observation. |
| hoglet_test.go | Test cleanups (rename sentinel, any usage). |
| breaker_test.go | Removes range-variable copies (safe given Go 1.24 toolchain). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
… nil error Co-authored-by: costela <94699+costela@users.noreply.github.com> Agent-Logs-Url: https://github.com/exaring/hoglet/sessions/62208c78-9047-4dc5-9ff2-e590c8dd3af3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
isFailurecalls inhoglet.gowitherr != nilso that nil errors are always treated as successes without invoking the user-provided failure condition functionIgnoreContextCanceledand updateWithFailureConditiondocs to reflect the new contractsentinel→errSentinel, useanyoverinterface{}, remove unnecessary loop variable copies (Go 1.22+)nilerrorTest plan
go test ./...)nilerrors🤖 Generated with Claude Code
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.