namespace SWP.Core.CommandQueries;
///
/// Represents a standardized error response according to RFC 9457 (Problem Details for HTTP APIs).
/// This class provides a consistent way to communicate errors in HTTP APIs, including details about the error type,
/// status code, and additional context. It also supports extensions for custom error information.
///
/// RFC 9457 Documentation: https://www.rfc-editor.org/rfc/rfc9457.html
///
public class ProblemDetails
{
///
/// A URI reference that identifies the problem type. This is typically a link to human-readable documentation about the error.
///
public string Type { get; set; }
///
/// A short, human-readable summary of the problem. It should not change between occurrences of the same error.
///
public string Title { get; set; }
///
/// The HTTP status code generated by the server for this occurrence of the problem. This allows the client to understand the general category of the error.
///
public int? Status { get; set; }
///
/// A human-readable explanation specific to this occurrence of the problem. It provides additional details about the error.
///
public string Detail { get; set; }
///
/// A URI reference that identifies the specific occurrence of the problem. This can be used to trace the error in logs or debugging tools.
///
public string Instance { get; set; }
///
/// A dictionary for additional, custom error information. This allows extending the problem details with application-specific fields.
///
[Newtonsoft.Json.JsonExtensionData]
public Dictionary Extensions { get; } = new();
///
/// Adds a custom extension to the problem details.
///
/// The key for the extension.
/// The value of the extension.
public void AddExtension(string key, object value) => Extensions.Add(key, value);
///
/// Removes a custom extension from the problem details.
///
/// The key of the extension to remove.
public void RemoveExtension(string key) => Extensions.Remove(key);
}