Skip to content

Conversation

@robocanic
Copy link
Contributor

@robocanic robocanic commented Nov 7, 2025

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.

  • Docs
  • Installation
  • User Experience
  • Dubboctl
  • Console
  • Core Component

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.ErrorOf and 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.

@robocanic robocanic requested a review from Copilot November 7, 2025 15:33
Copy link
Contributor

Copilot AI left a 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.

@robocanic robocanic requested a review from Copilot November 8, 2025 01:35
Copy link
Contributor

Copilot AI left a 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.

@robocanic robocanic requested a review from Copilot November 9, 2025 07:47
Copy link
Contributor

Copilot AI left a 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.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 9, 2025

@robocanic robocanic merged commit 4aae206 into apache:develop Nov 9, 2025
5 checks passed
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