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.
|
/// Base exception for all domain-related exceptions.
|
||||||
/// Caught by the Exception Handling Middleware in the API layer.
|
/// Caught by the Exception Handling Middleware in the API layer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("This exception is deprecated. Use more specific exceptions for domain errors.")]
|
||||||
public abstract class DomainException : Exception
|
public abstract class DomainException : Exception
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
/// Exception thrown when domain validation fails (e.g., invalid Value Objects).
|
/// Exception thrown when domain validation fails (e.g., invalid Value Objects).
|
||||||
/// Maps to HTTP 400 Bad Request in the API layer.
|
/// Maps to HTTP 400 Bad Request in the API layer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("This exception is deprecated. Use more specific exceptions for domain validation errors.")]
|
||||||
public class DomainValidationException : DomainException
|
public class DomainValidationException : DomainException
|
||||||
{
|
{
|
||||||
public string PropertyName { get; }
|
public string PropertyName { get; }
|
||||||
|
|||||||
@@ -1,25 +1,22 @@
|
|||||||
namespace DocumentOperator.Domain.Common.Exceptions;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace DocumentOperator.Domain.Common.Exceptions;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Exception thrown when a requested resource is not found.
|
/// Exception thrown when a requested resource is not found.
|
||||||
/// Maps to HTTP 404 Not Found in the API layer.
|
/// Maps to HTTP 404 Not Found in the API layer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class NotFoundException : DomainException
|
public class NotFoundException : Exception
|
||||||
{
|
{
|
||||||
public string ResourceType { get; }
|
public NotFoundException()
|
||||||
public object ResourceId { get; }
|
|
||||||
|
|
||||||
public NotFoundException(string resourceType, object resourceId)
|
|
||||||
: base($"{resourceType} with ID '{resourceId}' was not found.", "RESOURCE_NOT_FOUND")
|
|
||||||
{
|
{
|
||||||
ResourceType = resourceType;
|
|
||||||
ResourceId = resourceId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotFoundException(string resourceType, object resourceId, string customMessage)
|
public NotFoundException(string? message) : base(message)
|
||||||
: base(customMessage, "RESOURCE_NOT_FOUND")
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotFoundException(string? message, Exception? innerException) : base(message, innerException)
|
||||||
{
|
{
|
||||||
ResourceType = resourceType;
|
|
||||||
ResourceId = resourceId;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
/// Exception thrown when PDF processing operations fail.
|
/// Exception thrown when PDF processing operations fail.
|
||||||
/// Maps to HTTP 500 Internal Server Error or 422 Unprocessable Entity in the API layer.
|
/// Maps to HTTP 500 Internal Server Error or 422 Unprocessable Entity in the API layer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("This exception is deprecated. Use more specific exceptions for PDF processing errors.")]
|
||||||
public class PdfProcessingException : DomainException
|
public class PdfProcessingException : DomainException
|
||||||
{
|
{
|
||||||
public string Operation { get; }
|
public string Operation { get; }
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace DocumentOperator.Domain.Exceptions;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Exception thrown when a Swiss QR Code cannot be found in a PDF document.
|
/// Exception thrown when a Swiss QR Code cannot be found in a PDF document.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("This exception is deprecated. Use SwissQrCodeNotFoundException instead.")]
|
||||||
public sealed class SwissQrCodeNotFoundException : Exception
|
public sealed class SwissQrCodeNotFoundException : Exception
|
||||||
{
|
{
|
||||||
public SwissQrCodeNotFoundException()
|
public SwissQrCodeNotFoundException()
|
||||||
|
|||||||
Reference in New Issue
Block a user