Skip to content

Commit

Permalink
exceptionHandler handle domain exception
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidEggenberger committed Jan 5, 2025
1 parent babd7b3 commit c5c08ac
Show file tree
Hide file tree
Showing 40 changed files with 62 additions and 88 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using Modules.Subscriptions.Features.DomainFeatures.StripeSubscriptions;
using Shared.Features.Domain;

namespace Modules.Subscriptions.Features.DomainFeatures.StripeCustomers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Shared.Kernel.BuildingBlocks;
using Shared.Kernel.BuildingBlocks.IntegrationEvents;
using Shared.Kernel.DomainKernel;

namespace Modules.Subscriptions.Public.IntegrationEvents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Shared.Features.Server;
using Modules.Subscriptions.Features.DomainFeatures.StripeSubscriptions.Application.Commands;
using Modules.Subscriptions.Features;
using Stripe.V2;

namespace Modules.Subscriptions.Web.Server.WebHooks
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Shared.Features.EFCore;
using Shared.Features.Messaging.Commands;
using Shared.Features.Server;
using Shared.Kernel.BuildingBlocks.Auth;
using Shared.Kernel.DomainKernel;
using System.Threading;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Shared.Features.Messaging.Commands;
using Shared.Features.Server;
using Shared.Kernel.BuildingBlocks.Auth;
using Shared.Kernel.DomainKernel;
using System.Threading;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using Shared.Features.EFCore.Configuration;
using Modules.TenantIdentity.Features.DomainFeatures.Users;
using Shared.Features.EFCore;
using Shared.Kernel.BuildingBlocks;
using Modules.TenantIdentity.Features.DomainFeatures.Tenants.Domain;
using Shared.Features.Errors;
using Shared.Features.Server.ExecutionContext;

namespace Modules.TenantIdentity.Features.Infrastructure.EFCore
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Shared.Kernel.DomainKernel;
using System.Collections.Generic;

namespace Modules.TenantIdentity.Public.DTOs.Tenant
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Modules.TenantIdentity.Public.DTOs.Tenant
namespace Modules.TenantIdentity.Public.DTOs.Tenant
{
public class TenantInvitationDTO
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Shared.Kernel.BuildingBlocks;
using Shared.Kernel.BuildingBlocks.IntegrationEvents;
using System;

namespace Modules.TenantIdentity.Public.IntegrationEvents
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Shared.Kernel.BuildingBlocks;
using Shared.Kernel.BuildingBlocks.IntegrationEvents;
using System;

namespace Modules.TenantIdentity.Public.IntegrationEvents
Expand Down
5 changes: 0 additions & 5 deletions Source/Shared/Client/Components/Modals/DeletionModal.razor.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using Microsoft.AspNetCore.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shared.Client.Components.Modals
{
Expand Down
5 changes: 0 additions & 5 deletions Source/Shared/Client/Components/Modals/ErrorModal.razor.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using Microsoft.AspNetCore.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shared.Client.Components.Modals
{
Expand Down
7 changes: 1 addition & 6 deletions Source/Shared/Client/Types/ProblemDetails.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using System.Text.Json.Serialization;

namespace Shared.Client.Types
{
Expand Down
8 changes: 3 additions & 5 deletions Source/Shared/Features/Domain/Entity.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using Shared.Kernel.BuildingBlocks;
using Shared.Kernel.Interfaces;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Shared.Kernel.BuildingBlocks.Auth.Exceptions;
using Shared.Kernel.DomainKernel;
using Shared.Kernel.BuildingBlocks.Auth;
using Shared.Features.Errors;
using Shared.Features.Server.ExecutionContext;
using Shared.Kernel.DomainKernel.Interfaces;

namespace Shared.Features.Domain
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Shared/Features/EFCore/BaseDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using Shared.Features.EFCore.Configuration;
using Shared.Features.EFCore.MultiTenancy;
using Shared.Features.EFCore.MultiTenancy.Exceptions;
using Shared.Kernel.BuildingBlocks;
using Shared.Kernel.Interfaces;
using Shared.Features.Server.ExecutionContext;
using Shared.Kernel.DomainKernel.Interfaces;

namespace Shared.Features.EFCore
{
Expand Down
3 changes: 1 addition & 2 deletions Source/Shared/Features/EFCore/DbUp/Registrator.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using DbUp;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Shared.Features.EFCore.Configuration;
using Shared.Kernel.BuildingBlocks;
using Shared.Features.Server.ExecutionContext;
using System.Reflection;

namespace Shared.Features.EFCore.DbUp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Shared.Features.Domain;
using Shared.Kernel.BuildingBlocks;
using Shared.Features.Server.ExecutionContext;

namespace Shared.Features.EFCore
{
Expand Down
6 changes: 1 addition & 5 deletions Source/Shared/Features/Messaging/Commands/ICommandHandler.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Shared.Features.Modules;
using Shared.Features.Server;

namespace Shared.Features.Messaging.Commands
namespace Shared.Features.Messaging.Commands
{
public interface ICommandHandler<in TCommand> where TCommand : Command
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Shared.Kernel.BuildingBlocks;
using Shared.Kernel.BuildingBlocks.IntegrationEvents;

namespace Shared.Features.Messaging.IntegrationEvents
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Shared.Kernel.BuildingBlocks;
using Shared.Kernel.BuildingBlocks.IntegrationEvents;

namespace Shared.Features.Messaging.IntegrationEvents
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Shared.Kernel.BuildingBlocks;
using Shared.Kernel.BuildingBlocks.IntegrationEvents;

namespace Shared.Features.Messaging.IntegrationEvents
{
Expand Down
5 changes: 2 additions & 3 deletions Source/Shared/Features/Messaging/Queries/QueryDispatcher.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.DependencyInjection;
using Shared.Kernel.BuildingBlocks;
using Microsoft.Extensions.DependencyInjection;
using Shared.Features.Server.ExecutionContext;

namespace Shared.Features.Messaging.Queries
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/Features/Server/BaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Shared.Features.Messaging.Commands;
using Shared.Features.Messaging.IntegrationEvents;
using Shared.Features.Messaging.Queries;
using Shared.Kernel.BuildingBlocks;
using Shared.Features.Server.ExecutionContext;
using Shared.Kernel.BuildingBlocks.Services.ModelValidation;

namespace Shared.Features.Server
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Microsoft.Extensions.Hosting;
using Shared.Kernel.DomainKernel;


namespace Shared.Kernel.BuildingBlocks
namespace Shared.Features.Server.ExecutionContext
{
public interface IExecutionContext
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Shared.Kernel.BuildingBlocks;

namespace Shared.Features.Server.ExecutionContext
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Shared.Kernel.BuildingBlocks;
using Shared.Kernel.DomainKernel;
using Shared.Kernel.Extensions.ClaimsPrincipal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Shared.Kernel.BuildingBlocks;

namespace Shared.Features.Server.ExecutionContext
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/Features/Server/ServerExecutionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using Shared.Features.Messaging.IntegrationEvents;
using Shared.Features.Messaging.Queries;
using Shared.Features.Modules;
using Shared.Features.Server.ExecutionContext;
using Shared.Features.SignalR;
using Shared.Kernel.BuildingBlocks;
using Shared.Kernel.BuildingBlocks.Services.ModelValidation;

namespace Shared.Features.Server
Expand Down

This file was deleted.

6 changes: 0 additions & 6 deletions Source/Shared/Kernel/BuildingBlocks/IIntegrationEvent.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Shared.Kernel.BuildingBlocks.IntegrationEvents
{
public interface IIntegrationEvent
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Shared.Kernel.BuildingBlocks.IntegrationEvents
{
public interface IIntegrationRequest<TResponse>
{
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Shared.Kernel.Interfaces
namespace Shared.Kernel.DomainKernel.Interfaces
{
public interface IAuditable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Shared.Kernel.Interfaces
namespace Shared.Kernel.DomainKernel.Interfaces
{
public interface IConcurrent
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Shared.Kernel.Interfaces
namespace Shared.Kernel.DomainKernel.Interfaces
{
public interface IIdentifiable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Shared.Kernel.Interfaces
namespace Shared.Kernel.DomainKernel.Interfaces
{
public interface ITenantIdentifiable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Shared.Kernel.Interfaces
namespace Shared.Kernel.DomainKernel.Interfaces
{
public interface IUserIdentifiable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Shared.Features.Errors.Exceptions;
using Shared.Kernel.BuildingBlocks.Auth.Exceptions;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
Expand All @@ -24,7 +23,8 @@ public ExceptionHandler(ILogger<ExceptionHandler> logger)
exceptionHandlers = new Dictionary<Type, Func<Exception, Task<ActionResult>>>
{
[typeof(NotFoundException)] = HandleNotFoundException,
[typeof(UnauthorizedException)] = HandleUnauthorizedException
[typeof(UnAuthorizedException)] = HandleUnauthorizedException,
[typeof(DomainException)] = HandleDomainException
};
}

Expand Down Expand Up @@ -54,6 +54,7 @@ private async Task<ActionResult> HandleNotFoundException(Exception exception)
};
return new ObjectResult(problemDetails);
}

private async Task<ActionResult> HandleUnauthorizedException(Exception exception)
{
ProblemDetails problemDetails = new ProblemDetails
Expand All @@ -63,6 +64,18 @@ private async Task<ActionResult> HandleUnauthorizedException(Exception exception
};
return new ObjectResult(exception.Message);
}

private async Task<ActionResult> HandleDomainException(Exception exception)
{
var domainException = exception as DomainException;
ProblemDetails problemDetails = new ProblemDetails
{
Status = domainException.StatusCode,
Title = domainException.Message
};
return new ObjectResult(exception.Message);
}

private async Task<ActionResult> HandleUnknownExceptionAsync(Exception exception)
{
ProblemDetails problemDetails = new ProblemDetails
Expand Down
14 changes: 7 additions & 7 deletions Source/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ module.exports = {
'primary-800': '#075985',
'primary-900': '#0c4a6e'
},
screens: {
'xs': { 'raw': '(min-width: 0px)' },
'sm': { 'raw': '(min-width: 480px)' },
'md': { 'raw': '(min-width: 768px)' },
'lg': { 'raw': '(min-width: 1024px)' },
'xl': { 'raw': '(min-width: 1280px)' }
}
screens: {
'xs': { 'raw': '(min-width: 0px)' },
'sm': { 'raw': '(min-width: 480px)' },
'md': { 'raw': '(min-width: 768px)' },
'lg': { 'raw': '(min-width: 1024px)' },
'xl': { 'raw': '(min-width: 1280px)' }
}
},
plugins: [],
}
Expand Down

0 comments on commit c5c08ac

Please sign in to comment.