using System;
namespace ECMJobRunner.Application.Common.Exceptions
{
///
/// Exception for HTTP client-related job failures (e.g., ReC API calls, REST requests)
/// Extends JobException with client library and method context
///
public class JobHttpException : JobException
{
///
/// Initializes a new instance of JobHttpException with HTTP client context
///
/// Name of the job that failed (e.g., "ReC Request", "API Call")
/// Name of the process/stage being executed
/// Unique batch identifier for tracking
/// Human-readable reason for the failure (nullable)
/// Name of the HTTP client library used (e.g., "ReC.Client", "HttpClient") (nullable)
/// Name of the client method that failed (e.g., "ExecuteAsync", "PostAsync") (nullable)
/// The underlying exception that caused the failure (nullable)
///
/// Use this exception for HTTP-related failures such as:
/// - ReC API request failures
/// - REST API communication errors
/// - HTTP client timeout/network issues
/// - Authentication/authorization failures
///
public JobHttpException(string jobName, string processName, string batchId, string? reason, string? clientLibrary, string? clientMethod, Exception? innerException) : base(jobName, processName, batchId, reason, innerException,
("Client Library", clientLibrary, true),
("Client Method", clientMethod, true))
{
ClientLibrary = clientLibrary;
ClientMethod = clientMethod;
}
///
/// Gets the name of the HTTP client library that was used (e.g., "ReC.Client", "HttpClient")
///
public string? ClientLibrary { get; }
///
/// Gets the name of the client method that failed (e.g., "ExecuteAsync", "PostAsync")
///
public string? ClientMethod { get; }
}
}