Skip to content
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
1 change: 1 addition & 0 deletions src/TailoredApps.Shared.Email/SmtpEmailProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public static void RegisterConsoleProvider(this IServiceCollection services)



/// <summary>Wczytuje opcje SMTP z konfiguracji aplikacji.</summary>
public class SmtpEmailConfigureOptions : IConfigureOptions<SmtpEmailServiceOptions>
{
private readonly IConfiguration configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using TailoredApps.Shared.ExceptionHandling.Model;

namespace TailoredApps.Shared.ExceptionHandling.HttpResult
{
public class ExceptionOccuredResult : ObjectResult
{
public ExceptionOccuredResult(ModelStateDictionary modelState)
: base(modelState)
{
StatusCode = StatusCodes.Status400BadRequest;
}



public ExceptionOccuredResult(ExceptionHandlingResultModel modelState)
: base(modelState)
{
StatusCode = StatusCodes.Status400BadRequest;
}
}
}
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using TailoredApps.Shared.ExceptionHandling.Model;

namespace TailoredApps.Shared.ExceptionHandling.HttpResult
{
/// <summary>Wynik HTTP 400 zwracany gdy wystąpi wyjątek lub błąd walidacji.</summary>
public class ExceptionOccuredResult : ObjectResult
{
/// <summary>Inicjalizuje wynik 400 z błędami walidacji modelu.</summary>
public ExceptionOccuredResult(ModelStateDictionary modelState)
: base(modelState)
{
StatusCode = StatusCodes.Status400BadRequest;
}

/// <summary>Inicjalizuje wynik 400 z modelem odpowiedzi wyjątku.</summary>
public ExceptionOccuredResult(ExceptionHandlingResultModel modelState)
: base(modelState)
{
StatusCode = StatusCodes.Status400BadRequest;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
using Microsoft.Extensions.DependencyInjection;
using System;

namespace TailoredApps.Shared.ExceptionHandling.Interfaces
{
public interface IExceptionHandlingOptionsBuilder
{
IExceptionHandlingOptionsBuilder WithExceptionHandlingProvider<Provider>() where Provider : class, IExceptionHandlingProvider;
IExceptionHandlingOptionsBuilder WithExceptionHandlingProvider<Provider>(Func<IServiceProvider, Provider> implementationFactory) where Provider : class, IExceptionHandlingProvider;
IServiceCollection Services { get; }
}
}
using Microsoft.Extensions.DependencyInjection;
using System;

namespace TailoredApps.Shared.ExceptionHandling.Interfaces
{
/// <summary>Builder do konfigurowania dostawców obsługi wyjątków w DI.</summary>
public interface IExceptionHandlingOptionsBuilder
{
/// <summary>Rejestruje dostawcę obsługi wyjątków (automatyczna aktywacja przez DI).</summary>
IExceptionHandlingOptionsBuilder WithExceptionHandlingProvider<Provider>() where Provider : class, IExceptionHandlingProvider;

/// <summary>Rejestruje dostawcę obsługi wyjątków z fabryczną metodą tworzenia instancji.</summary>
IExceptionHandlingOptionsBuilder WithExceptionHandlingProvider<Provider>(Func<IServiceProvider, Provider> implementationFactory) where Provider : class, IExceptionHandlingProvider;

/// <summary>Kolekcja usług DI, do której rejestrowane są dostawcy.</summary>
IServiceCollection Services { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using Microsoft.AspNetCore.Mvc.ModelBinding;
using System;
using TailoredApps.Shared.ExceptionHandling.Model;

namespace TailoredApps.Shared.ExceptionHandling.Interfaces
{
public interface IExceptionHandlingProvider
{
ExceptionHandlingResultModel Response(Exception exception);
ExceptionHandlingResultModel Response(ModelStateDictionary modelState);
}
}
using Microsoft.AspNetCore.Mvc.ModelBinding;
using System;
using TailoredApps.Shared.ExceptionHandling.Model;

namespace TailoredApps.Shared.ExceptionHandling.Interfaces
{
/// <summary>Interfejs dostawcy obsługi wyjątków — mapuje wyjątki na modele odpowiedzi HTTP.</summary>
public interface IExceptionHandlingProvider
{
/// <summary>Tworzy model odpowiedzi dla danego wyjątku.</summary>
ExceptionHandlingResultModel Response(Exception exception);

/// <summary>Tworzy model odpowiedzi dla błędów walidacji modelu.</summary>
ExceptionHandlingResultModel Response(ModelStateDictionary modelState);
}
}
Loading
Loading