-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: Defined a unified error #1353
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: Defined a unified error #1353
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors error handling across the console package by introducing a structured bizerror package with typed error codes, moving business logic from handlers to the service layer, and standardizing API response formats. The changes improve code maintainability and consistency by centralizing error handling and separating concerns between presentation and business logic layers.
Key changes:
- Introduces structured error types with error codes (InvalidArgument, AppNotFound, Unauthorized, etc.)
- Migrates application configuration logic (access log, flow weight, gray config) from handlers to service layer
- Standardizes HTTP responses to use consistent error response format with string-based error codes
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/common/bizerror/error.go | New error type definitions and error code constants for structured error handling |
| pkg/common/bizerror/common.go | Refactored helper functions to return typed Error interface instead of standard errors |
| pkg/console/util/error.go | New utility functions for handling service and argument errors consistently in handlers |
| pkg/console/model/common.go | Updated response structure with string-based error codes and new error response constructors |
| pkg/console/model/application.go | Added response types for access log, flow weight, and gray configuration |
| pkg/console/model/tag_rule.go | Standardized response generation to return success with nil instead of 404 errors |
| pkg/console/model/configurator_rule.go | Standardized response generation for missing configurators |
| pkg/console/model/condition_rule.go | Updated error responses to use new error response format |
| pkg/console/service/application.go | New service layer functions for managing access log, flow weight, and gray configurations |
| pkg/console/handler/application.go | Refactored handlers to use service layer and centralized error handling utilities |
| pkg/console/handler/auth.go | Updated authentication handlers to use new error response format |
| pkg/console/component.go | Updated middleware to use structured error responses |
| pkg/console/router/router.go | Renamed handler functions from OperatorLog to AccessLog for clarity |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|



Please provide a description of this PR:
Defined a unified error and separate application domain into handler and service, make it more reasonable. Refer to #1337
To help us figure out who should review this PR, please put an X in all the areas that this PR affects.
Please check any characteristics that apply to this pull request.
In the past, we don't have a unified error, when we defined an error, we usually wrap it with
fmt.ErrorOfand return it, when the error returned to console handler, we cannot recognize the type of error. So the error message showed in the frontend is in a mess. So unifying the error code is needed. The pr also provide a example refractor of error handle and service separation.