Skip to content

refactor: introduce HttpResponseException and update factories#227

Open
kevmoo wants to merge 11 commits intogoogleapis:mainfrom
kevmoo:alias_fun
Open

refactor: introduce HttpResponseException and update factories#227
kevmoo wants to merge 11 commits intogoogleapis:mainfrom
kevmoo:alias_fun

Conversation

@kevmoo
Copy link
Copy Markdown
Contributor

@kevmoo kevmoo commented Apr 2, 2026

  • Rename bad_request_exception.dart to http_response_exception.dart and introduce HttpResponseException to replace BadRequestException (now a typedef alias for backward compatibility).
  • Deprecate badRequestMiddleware in favor of httpResponseExceptionMiddleware.
  • Make message a named parameter in all HttpResponseException factory constructors.
  • Provide default HTTP status messages (e.g., 'Bad Request', 'Not Found') if message is null.
  • Update callers in example/example.dart and test/logging_test.dart to use named arguments or remove redundant ones.
  • Document default behavior in doc comments using standard Dart style.
  • Update CHANGELOG.md to use precise "Introduces" language.

- Rename `bad_request_exception.dart` to `http_response_exception.dart` and introduce `HttpResponseException` to replace `BadRequestException` (now a typedef alias for backward compatibility).
- Deprecate `badRequestMiddleware` in favor of `httpResponseExceptionMiddleware`.
- Make `message` a named parameter in all `HttpResponseException` factory constructors.
- Provide default HTTP status messages (e.g., 'Bad Request', 'Not Found') if `message` is null.
- Update callers in `example/example.dart` and `test/logging_test.dart` to use named arguments or remove redundant ones.
- Document default behavior in doc comments using standard Dart style.
- Update `CHANGELOG.md` to use precise "Introduces" language.
@kevmoo kevmoo requested a review from brianquinlan April 2, 2026 02:38
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces HttpResponseException and httpResponseExceptionMiddleware, deprecating the previous BadRequestException and badRequestMiddleware. The new exception class expands support to include 5XX status codes and provides factory constructors for common HTTP errors with default messages and gRPC-aligned status strings. Logging middleware has been updated to handle these exceptions and include structured error payloads in Google Cloud logs. Feedback includes fixing a typo in the changelog, updating documentation to reflect the expanded status code range, and adding missing default status values for the new 5XX factory constructors to ensure consistency with AIP-193.

@kevmoo
Copy link
Copy Markdown
Contributor Author

kevmoo commented Apr 2, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces HttpResponseException and httpResponseExceptionMiddleware, deprecating BadRequestException and its associated middleware. The new exception class expands support to HTTP 5XX status codes and structured error reporting. Review feedback identifies that changing factory constructor parameters from positional to named is a breaking change, which contradicts the goal of backward compatibility. Additionally, it is recommended to update the logging logic to use LogSeverity.error for 5XX status codes instead of a hardcoded warning level.

@kevmoo
Copy link
Copy Markdown
Contributor Author

kevmoo commented Apr 2, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces HttpResponseException and httpResponseExceptionMiddleware, deprecating the BadRequestException equivalents while adding support for 5XX status codes and structured error reporting. It also includes a new utility for header-based JSON response negotiation. Feedback points out that changing factory constructor parameters from positional to named is a breaking change that may require a version bump to 0.5.0. Additionally, the mime package was added as a dependency but remains unused in the implementation.

@kevmoo
Copy link
Copy Markdown
Contributor Author

kevmoo commented Apr 3, 2026

@brianquinlan – I'd love to publish this tomorrow (Friday) – final thoughts?

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