Skip to content

Conversation

Linzyoo
Copy link
Contributor

@Linzyoo Linzyoo commented Aug 24, 2024

Describe what this PR does / why we need it

This PR is to update DefaultExceptionHandler with appropriate httpstatus code and message for different types of BlockException.

Does this pull request fix one issue?

Fixes #3443

Describe how you did it

Create an enum for all BlockException and set appropriate httpstatus code and message.

Describe how to verify it

Add test cases for DefaultExceptionHandler

Special notes for reviews

# Conflicts:
#	sentinel-adapter/sentinel-spring-webmvc-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/spring/webmvc/AbstractSentinelInterceptor.java
#	sentinel-demo/sentinel-demo-spring-webmvc/src/main/java/com/alibaba/csp/sentinel/demo/spring/webmvc/config/InterceptorConfig.java
2. improve based on review comments
@Linzyoo Linzyoo changed the title Fix 3443 Fix 3443 to set appropriate httpstatus codes and messages for different types of BlockException Aug 24, 2024
@LearningGp LearningGp self-requested a review August 29, 2024 13:03
@LearningGp
Copy link
Collaborator

Maintaining consistency in the exceptions DefaultBlockExceptionHandler throws is advisable. In typical use cases, users uniformly handle traffic control exceptions from Sentinel (notably AuthorityException, which serves as an edge case not central to Sentinel's core functionality). Recommended practices suggest allowing users to implement their own BlockExceptionHandler interface to clearly differentiate these exceptions during implementation.

@LearningGp LearningGp added kind/enhancement Category issues or prs related to enhancement. area/integrations Issues or PRs related to integrations with open-source components wait-for-response PRs that require further response labels Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/integrations Issues or PRs related to integrations with open-source components kind/enhancement Category issues or prs related to enhancement. wait-for-response PRs that require further response
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] DefaultBlockExceptionHandler treats all BlockException as FlowException
2 participants