Skip to content

Conversation

@imhmdi
Copy link
Member

@imhmdi imhmdi commented May 27, 2025

added NotFoundBusinessException

PR Classification

Enhancement of error handling and message reporting in the application.

PR Summary

This pull request introduces nullable parameters for error messages and adds a new exception type for better error handling. Key changes include:

  • ResultMessage.cs: Updated to use nullable string types for code and field parameters.
  • ResultMessagesExtensions.cs: Modified AppendError methods to accept nullable parameters.
  • NotFoundBusinessException.cs: Introduced a new exception class for handling not found scenarios.
  • ExceptionCommandHandlerDecorator.cs: Added handling for NotFoundBusinessException to set appropriate result status.
  • ExceptionHandlingInterceptor.cs: Enhanced error logging and added handling for NotFoundBusinessException.

@imhmdi imhmdi requested a review from Copilot May 27, 2025 16:01
Copy link

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@imhmdi imhmdi requested a review from Copilot May 27, 2025 16:11
Copy link

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 pull request enhances error handling by introducing nullable parameters for error messages and adding a new exception type for not-found scenarios. Key changes include:

  • Updated exception handling in interceptors and command handler decorators to account for NotFoundBusinessException.
  • Added NotFoundBusinessException with a default not-found message.
  • Modified ResultMessagesExtensions and ResultMessage to support nullable parameters.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Facade/Default/Interceptors/ExceptionHandlingInterceptor.cs Adjusts error handling logic by passing error messages as parameters.
src/Facade/Default/Honamic.Framework.Facade.csproj Adds reference to the Domain.Abstractions project.
src/Core/Domain.Abstractions/NotFoundBusinessException.cs Introduces NotFoundBusinessException with a default message.
src/Core/Applications/CommandHandlerDecorators/ExceptionCommandHandlerDecorator.cs Adds new case handling for NotFoundBusinessException.
src/Core/Applications.Abstractions/Results/ResultMessagesExtensions.cs Updates AppendError methods to accept nullable string values.
src/Core/Applications.Abstractions/Results/ResultMessage.cs Changes constructor and properties for nullable error message parameters.
Comments suppressed due to low confidence (1)

src/Core/Applications.Abstractions/Results/ResultMessage.cs:5

  • The parameter order in the updated ResultMessage constructor has been reversed compared to its previous version. This causes the 'field' and 'code' values to be swapped when called by the AppendError methods; please revert the order or update all call sites accordingly.
public ResultMessage(ResultMessageType type, string message, string? code = null, string? field = null)

@imhmdi imhmdi requested a review from Copilot May 27, 2025 16:36
Copy link

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 enhances error handling by introducing a new NotFoundBusinessException and updating related error reporting methods to support nullable parameters.

  • Updates exception handling in interceptors and command handler decorators to include NotFound scenarios.
  • Refactors ResultMessagesExtensions and ResultMessage to use nullable types for improved error messaging.
  • Updates project references and build workflow configuration to support the changes.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Facade/Default/Interceptors/ExceptionHandlingInterceptor.cs Adds NotFoundBusinessException handling and updates error method calls
src/Facade/Default/Honamic.Framework.Facade.csproj Adds a project reference for domain abstractions
src/Core/Domain.Abstractions/NotFoundBusinessException.cs Introduces a new exception class for not found scenarios
src/Core/Applications/CommandHandlerDecorators/ExceptionCommandHandlerDecorator.cs Incorporates NotFoundBusinessException in command error handling
src/Core/Applications.Abstractions/Results/ResultMessagesExtensions.cs Updates AppendError overloads to accept nullable parameters
src/Core/Applications.Abstractions/Results/ResultMessage.cs Updates properties to allow null values for field and code
.github/workflows/build.yml Refines build workflow trigger configuration

Comment on lines 112 to 116
switch (ex)
{
case UnauthenticatedException:
rawResult?.SetStatusAsUnauthenticated();
rawResult?.AppendError(ex.Message, "Exception");
rawResult.SetStatusAsUnauthenticated(ex.Message);
break;
Copy link

Copilot AI May 27, 2025

Choose a reason for hiding this comment

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

Consider ensuring that the null handling of 'rawResult' is consistent across all exception cases; some cases use the null-conditional operator while others do not, so validating the non-null assumption here might help avoid potential issues.

Copilot uses AI. Check for mistakes.
Comment on lines 131 to +132
rawResult?.SetStatusAsUnhandledExceptionWithSorryError();
rawResult?.AppendError(ex.ToString(), "Exception");
rawResult?.AppendError(ex.Message, "Exception");
Copy link

Copilot AI May 27, 2025

Choose a reason for hiding this comment

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

Review the inconsistent use of the null-conditional operator on 'rawResult'; aligning its usage across all cases will improve code clarity and reduce ambiguity in error handling.

Copilot uses AI. Check for mistakes.
@imhmdi imhmdi requested a review from Copilot May 27, 2025 16:42
Copy link

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 enhances error handling by introducing a new NotFoundBusinessException and updating error reporting to support nullable error message parameters. Key changes include:

  • Introducing NotFoundBusinessException with a default error message.
  • Updating ExceptionHandlingInterceptor and ExceptionCommandHandlerDecorator to handle the new exception type.
  • Modifying ResultMessage and AppendError extension methods to support nullable string parameters.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Facade/Default/Interceptors/ExceptionHandlingInterceptor.cs Updated exception switch cases for improved error reporting.
src/Facade/Default/Honamic.Framework.Facade.csproj Added a project reference for domain abstractions.
src/Core/Domain.Abstractions/NotFoundBusinessException.cs Introduced the new exception class with a default message.
src/Core/Applications/CommandHandlerDecorators/ExceptionCommandHandlerDecorator.cs Added handling for NotFoundBusinessException in command handling.
src/Core/Applications.Abstractions/Results/ResultMessagesExtensions.cs Updated AppendError method signatures and added a new status setter.
src/Core/Applications.Abstractions/Results/ResultMessage.cs Modified the ResultMessage model for nullable error fields.
.github/workflows/build.yml Adjusted workflow triggers to restrict events to the main branch.

@imhmdi imhmdi merged commit 01405ce into main May 27, 2025
1 check passed
@imhmdi imhmdi deleted the NotFoundBusinessException branch October 10, 2025 08:40
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