- Replace DEXJobException with JobException base class - Flexible params-based detail collection - Automatic message formatting with visual separators - Optional null-handling for contextual details - Add JobHttpException for HTTP client failures - Properties: ClientLibrary, ClientMethod - Use case: ReC API, REST requests - Add JobSqlException for SQL query failures - Property: Query (virtual for customization) - Use case: Main/Check query execution - Comprehensive XML documentation for all exception classes
47 lines
2.1 KiB
C#
47 lines
2.1 KiB
C#
using System;
|
|
|
|
namespace ECMJobRunner.Application.Common.Exceptions
|
|
{
|
|
/// <summary>
|
|
/// Exception for SQL query execution failures
|
|
/// Extends JobException with SQL query context for debugging
|
|
/// </summary>
|
|
public class JobSqlException : JobException
|
|
{
|
|
/// <summary>
|
|
/// Initializes a new instance of JobSqlException with SQL query context
|
|
/// </summary>
|
|
/// <param name="jobName">Name of the job that failed (e.g., "Main Query Execution", "Check Query")</param>
|
|
/// <param name="processName">Name of the process/stage being executed</param>
|
|
/// <param name="batchId">Unique batch identifier for tracking</param>
|
|
/// <param name="reason">Human-readable reason for the failure (nullable)</param>
|
|
/// <param name="query">The SQL query that failed (nullable, for debugging purposes)</param>
|
|
/// <param name="innerException">The underlying SQL exception (nullable)</param>
|
|
/// <remarks>
|
|
/// 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.
|
|
/// </remarks>
|
|
public JobSqlException(string jobName, string processName, string batchId, string? reason, string? query, Exception? innerException) : base(jobName, processName, batchId, reason, innerException,
|
|
("Query", query, true))
|
|
{
|
|
Query = query;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the SQL query that failed (nullable)
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This property is marked as virtual to allow derived classes to customize query handling
|
|
/// (e.g., sanitizing sensitive data, truncating long queries)
|
|
/// </remarks>
|
|
public virtual string? Query { get; }
|
|
}
|
|
}
|