Skip to content

Handle Before errors with OnUsageError#2380

Open
cyphercodes wants to merge 1 commit into
urfave:v2-maintfrom
cyphercodes:fix-before-on-usage-error
Open

Handle Before errors with OnUsageError#2380
cyphercodes wants to merge 1 commit into
urfave:v2-maintfrom
cyphercodes:fix-before-on-usage-error

Conversation

@cyphercodes

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • bug

What this PR does / why we need it:

  • Calls OnUsageError when a Before hook returns an error, matching the existing usage-error path and allowing applications to customize the returned error/output.
  • Preserves the existing fallback behavior when no OnUsageError handler is configured.
  • Adds a regression test for app-level Before errors and updates the operation-order expectations.

Which issue(s) this PR fixes:

Fixes #707

Special notes for your reviewer:

This is intentionally limited to the Before error path discussed in the issue.

Testing

  • go test ./...
  • go vet ./...
  • git diff --check

Release Notes

`Before` hook errors now invoke `OnUsageError` when configured.

@cyphercodes cyphercodes requested a review from a team as a code owner July 2, 2026 03:55
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.

1 participant