refactor: Make Domain exceptions serializable and add XML docs
- Add [Serializable] attribute to all custom exceptions - Add protected constructors for serialization support - Add XML documentation comments - Update SwissQrCodeNotFoundException message format
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
/// Base exception for all domain-related exceptions.
|
||||
/// Caught by the Exception Handling Middleware in the API layer.
|
||||
/// </summary>
|
||||
[Obsolete("This exception is deprecated. Use more specific exceptions for domain errors.")]
|
||||
public abstract class DomainException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
/// Exception thrown when domain validation fails (e.g., invalid Value Objects).
|
||||
/// Maps to HTTP 400 Bad Request in the API layer.
|
||||
/// </summary>
|
||||
[Obsolete("This exception is deprecated. Use more specific exceptions for domain validation errors.")]
|
||||
public class DomainValidationException : DomainException
|
||||
{
|
||||
public string PropertyName { get; }
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
namespace DocumentOperator.Domain.Common.Exceptions;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace DocumentOperator.Domain.Common.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// Exception thrown when a requested resource is not found.
|
||||
/// Maps to HTTP 404 Not Found in the API layer.
|
||||
/// </summary>
|
||||
public class NotFoundException : DomainException
|
||||
public class NotFoundException : Exception
|
||||
{
|
||||
public string ResourceType { get; }
|
||||
public object ResourceId { get; }
|
||||
|
||||
public NotFoundException(string resourceType, object resourceId)
|
||||
: base($"{resourceType} with ID '{resourceId}' was not found.", "RESOURCE_NOT_FOUND")
|
||||
public NotFoundException()
|
||||
{
|
||||
ResourceType = resourceType;
|
||||
ResourceId = resourceId;
|
||||
}
|
||||
|
||||
public NotFoundException(string resourceType, object resourceId, string customMessage)
|
||||
: base(customMessage, "RESOURCE_NOT_FOUND")
|
||||
public NotFoundException(string? message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public NotFoundException(string? message, Exception? innerException) : base(message, innerException)
|
||||
{
|
||||
ResourceType = resourceType;
|
||||
ResourceId = resourceId;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
/// Exception thrown when PDF processing operations fail.
|
||||
/// Maps to HTTP 500 Internal Server Error or 422 Unprocessable Entity in the API layer.
|
||||
/// </summary>
|
||||
[Obsolete("This exception is deprecated. Use more specific exceptions for PDF processing errors.")]
|
||||
public class PdfProcessingException : DomainException
|
||||
{
|
||||
public string Operation { get; }
|
||||
|
||||
Reference in New Issue
Block a user