Skip to content
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

Carbon exception message override improvements. #143

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>1.3.0</Version>
<Version>1.3.1</Version>
<Description>
1.3.1
- OverrideExceptionDetail is added
1.3.0
- UnauthorizedOperationException is added
1.2.2
Expand Down
2 changes: 2 additions & 0 deletions Carbon.ExceptionHandling/CarbonException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public abstract class CarbonException : Exception
/// </summary>
public object[] Arguments { get; set; }

public bool OverrideExceptionDetail { get; set; } = true;

/// <summary>
/// CarbonException with only error code 5000.
/// </summary>
Expand Down
5 changes: 3 additions & 2 deletions Carbon.WebApplication/Carbon.WebApplication.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1</TargetFrameworks>
<Version>4.5.4</Version>
<Version>4.5.6</Version>
<Description>
4.5.4
4.5.6
- Added a property named overrideMessageAndCode to the CarbonException class. The default value of this property is set to true. In the constructor of CarbonException, check this property to determine whether the message and code are overridden or not.
- Update IPageableDto validator for assign PageSize 0. When PageSize 0 the datas returns without pagination with development in version 4.5.3.
4.5.3
- Upgrade Carbon.PagedList (Remove pageSize and pageNumber validation check)
Expand Down
2 changes: 1 addition & 1 deletion Carbon.WebApplication/HttpGlobalExceptionFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void OnException(ExceptionContext context)

if (context.Exception is CarbonException exception)
{
if (!string.IsNullOrEmpty(_errorHandling))
if (!string.IsNullOrEmpty(_errorHandling) && exception.OverrideExceptionDetail)
{
var exceptionMessage = GetErrorMessage(exception.ErrorCode, exception.Arguments, context.HttpContext.Request).Result;

Expand Down
Loading