167 lines
5.8 KiB
C#
Executable File
167 lines
5.8 KiB
C#
Executable File
using System;
|
|
using System.Runtime.Serialization;
|
|
|
|
namespace MarketAlly.AIPlugin.Learning.Exceptions
|
|
{
|
|
/// <summary>
|
|
/// Base exception for all learning-related operations
|
|
/// </summary>
|
|
public abstract class LearningException : Exception
|
|
{
|
|
protected LearningException() { }
|
|
protected LearningException(string message) : base(message) { }
|
|
protected LearningException(string message, Exception innerException) : base(message, innerException) { }
|
|
protected LearningException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when compilation fails during learning iteration
|
|
/// </summary>
|
|
public class CompilationException : LearningException
|
|
{
|
|
public int ErrorCount { get; }
|
|
public int WarningCount { get; }
|
|
public string[] Errors { get; }
|
|
|
|
public CompilationException(int errorCount, int warningCount, string[] errors)
|
|
: base($"Compilation failed with {errorCount} errors and {warningCount} warnings")
|
|
{
|
|
ErrorCount = errorCount;
|
|
WarningCount = warningCount;
|
|
Errors = errors ?? Array.Empty<string>();
|
|
}
|
|
|
|
public CompilationException(string message, int errorCount, int warningCount, Exception innerException = null)
|
|
: base(message, innerException)
|
|
{
|
|
ErrorCount = errorCount;
|
|
WarningCount = warningCount;
|
|
Errors = Array.Empty<string>();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when RefactorIQ operations fail
|
|
/// </summary>
|
|
public class RefactorIQException : LearningException
|
|
{
|
|
public string Operation { get; }
|
|
|
|
public RefactorIQException(string operation, string message)
|
|
: base($"RefactorIQ {operation} failed: {message}")
|
|
{
|
|
Operation = operation;
|
|
}
|
|
|
|
public RefactorIQException(string operation, string message, Exception innerException)
|
|
: base($"RefactorIQ {operation} failed: {message}", innerException)
|
|
{
|
|
Operation = operation;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when learning iteration encounters critical errors
|
|
/// </summary>
|
|
public class LearningIterationException : LearningException
|
|
{
|
|
public int IterationNumber { get; }
|
|
public string Phase { get; }
|
|
|
|
public LearningIterationException(int iterationNumber, string phase, string message)
|
|
: base($"Learning iteration {iterationNumber} failed in {phase}: {message}")
|
|
{
|
|
IterationNumber = iterationNumber;
|
|
Phase = phase;
|
|
}
|
|
|
|
public LearningIterationException(int iterationNumber, string phase, string message, Exception innerException)
|
|
: base($"Learning iteration {iterationNumber} failed in {phase}: {message}", innerException)
|
|
{
|
|
IterationNumber = iterationNumber;
|
|
Phase = phase;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when Git operations fail
|
|
/// </summary>
|
|
public class GitOperationException : LearningException
|
|
{
|
|
public string Operation { get; }
|
|
public string RepositoryPath { get; }
|
|
|
|
public GitOperationException(string operation, string repositoryPath, string message)
|
|
: base($"Git {operation} failed in {repositoryPath}: {message}")
|
|
{
|
|
Operation = operation;
|
|
RepositoryPath = repositoryPath;
|
|
}
|
|
|
|
public GitOperationException(string operation, string repositoryPath, string message, Exception innerException)
|
|
: base($"Git {operation} failed in {repositoryPath}: {message}", innerException)
|
|
{
|
|
Operation = operation;
|
|
RepositoryPath = repositoryPath;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when AI services fail
|
|
/// </summary>
|
|
public class AIServiceException : LearningException
|
|
{
|
|
public string ServiceName { get; }
|
|
public bool IsRetryable { get; }
|
|
|
|
public AIServiceException(string serviceName, string message, bool isRetryable = true)
|
|
: base($"AI service {serviceName} failed: {message}")
|
|
{
|
|
ServiceName = serviceName;
|
|
IsRetryable = isRetryable;
|
|
}
|
|
|
|
public AIServiceException(string serviceName, string message, Exception innerException, bool isRetryable = true)
|
|
: base($"AI service {serviceName} failed: {message}", innerException)
|
|
{
|
|
ServiceName = serviceName;
|
|
IsRetryable = isRetryable;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when configuration is invalid
|
|
/// </summary>
|
|
public class ConfigurationException : LearningException
|
|
{
|
|
public string ConfigurationKey { get; }
|
|
|
|
public ConfigurationException(string configurationKey, string message)
|
|
: base($"Configuration error for '{configurationKey}': {message}")
|
|
{
|
|
ConfigurationKey = configurationKey;
|
|
}
|
|
|
|
public ConfigurationException(string configurationKey, string message, Exception innerException)
|
|
: base($"Configuration error for '{configurationKey}': {message}", innerException)
|
|
{
|
|
ConfigurationKey = configurationKey;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Exception thrown when security validation fails
|
|
/// </summary>
|
|
public class SecurityException : LearningException
|
|
{
|
|
public string Operation { get; }
|
|
public string Resource { get; }
|
|
|
|
public SecurityException(string operation, string resource, string message)
|
|
: base($"Security violation in {operation} for {resource}: {message}")
|
|
{
|
|
Operation = operation;
|
|
Resource = resource;
|
|
}
|
|
}
|
|
} |