using System;
namespace ECMJobRunner.Application.Common.Exceptions
{
///
/// Exception for SQL query execution failures
/// Extends JobException with SQL query context for debugging
///
///
/// Initializes a new instance of JobSqlException with SQL query context
///
/// Identifier of the profile associated with the job
/// Name of the job that failed (e.g., "Main Query Execution", "Check Query")
/// Name of the process/stage being executed
/// Unique batch identifier for tracking
/// Human-readable reason for the failure (nullable)
/// The SQL query that failed (nullable, for debugging purposes)
/// The underlying SQL exception (nullable)
///
/// Use this exception for SQL-related failures such as:
/// - Main query execution errors
/// - Check query validation failures
/// - Database connection issues
/// - SQL syntax errors
/// - Query timeout exceptions
///
/// The Query property can be logged for debugging but should be handled carefully
/// to avoid exposing sensitive data in production logs.
///
public class JobSqlException(long profileId, string jobName, string processName, string batchId, string? reason, string? query, Exception? innerException)
: JobException(profileId, jobName, processName, batchId, reason, innerException, ("Query", query, true))
{
///
/// Gets the SQL query that failed (nullable)
///
///
/// This property is marked as virtual to allow derived classes to customize query handling
/// (e.g., sanitizing sensitive data, truncating long queries)
///
public virtual string? Query { get; } = query;
}
}