using System;
using System.Diagnostics;
using AnticipatingMinds.PlatformServices.Globalization;
namespace AnticipatingMinds.Genesis.KnowledgeManagement{
/// <summary>
/// Represents a base class for all Knowledge Base related exceptions.
/// </summary>
[System.Serializable()]
public abstract class KnowledgeBaseException : ApplicationException
{
/// <summary>
/// Initializes new Instance of the <see cref="KnowledgeBaseException"/>
/// </summary>
/// <param name="innerException">Inner exception.</param>
/// <param name="messageId">Exception message id (in ExceptionMessages.resx.</param>
/// <param name="messageArguments">Message arguments.</param>
protected KnowledgeBaseException(Exception innerException, string messageId,params object[] messageArguments) :
base(string.Format(GetExceptionMessage(messageId),messageArguments),innerException)
{
}
private static string GetExceptionMessage(string exceptionMessageId)
{
if(exceptionsResourceManager == null)
exceptionsResourceManager = AssemblyResourceManager.GetInstance("AnticipatingMinds.Genesis.KnowledgeManagement.ExceptionMessages");
string fetchedString = exceptionsResourceManager.GetString(exceptionMessageId);
//Check that fetchedString is not null
Debug.Assert(fetchedString != null,string.Format("String resource '{0} was not found",exceptionMessageId));
if(fetchedString == null)
fetchedString = exceptionMessageId;
return fetchedString;
}
private static AssemblyResourceManager exceptionsResourceManager = null;
}
/// <summary>
/// Represents an exception thrown if rule template class cannot be instantiated.
/// </summary>
[Serializable]
public sealed class TemplateIsNotAvailableException : KnowledgeBaseException
{
/// <summary>
/// Initializes new instance of the <see cref="TemplateIsNotAvailableException"/> class.
/// </summary>
/// <param name="templateId">Template id.</param>
/// <param name="templateName">Template name.</param>
/// <param name="templateType">Full type name of the template class.</param>
/// <param name="innerException">Inner exception.</param>
public TemplateIsNotAvailableException(string templateId,string templateName,string templateType, Exception innerException) :
base(innerException,"TemplateIsNotAvailableException",templateId,templateName,templateType)
{
}
}
/// <summary>
/// Represents an exception thrown when a required property is set to empty or null.
/// </summary>
[Serializable]
public sealed class TemplatePropertyIsRequiredException: KnowledgeBaseException
{
/// <summary>
/// Initializes new instance of the <see cref="TemplatePropertyIsRequiredException"/> class.
/// </summary>
/// <param name="templateId">Template id.</param>
/// <param name="propertyName">Property name.</param>
public TemplatePropertyIsRequiredException(string templateId,string propertyName) :
base(null,"TemplatePropertyIsRequiredException",templateId,propertyName)
{
}
}
/// <summary>
/// Represents an exception thrown if specified template class is not inherited from <see cref="RuleTemplate"/> class.
/// </summary>
[Serializable]
public sealed class InvalidRuleTemplateTypeException: KnowledgeBaseException
{
/// <summary>
/// Initializes new instance of the <see cref="InvalidRuleTemplateTypeException"/> class.
/// </summary>
/// <param name="templateId">Template id.</param>
/// <param name="templateName">Template name.</param>
public InvalidRuleTemplateTypeException(string templateId,string templateName) :
base(null,"InvalidRuleTemplateType",templateId,templateName)
{
}
}
/// <summary>
/// Represents an exception thrown when a required property is set to empty or null.
/// </summary>
[Serializable]
public sealed class RulePropertyIsRequiredException: KnowledgeBaseException
{
/// <summary>
/// Initializes new instance of the <see cref="RulePropertyIsRequiredException"/> class.
/// </summary>
/// <param name="ruleId">Rule id.</param>
/// <param name="propertyName">Property name.</param>
public RulePropertyIsRequiredException(string ruleId,string propertyName) :
base(null,"RulePropertyIsRequiredException",ruleId,propertyName)
{
}
}
/// <summary>
/// Represents an exception thrown if new rule is created with rule id that already exists in the Knowledge Base.
/// </summary>
[Serializable]
public sealed class DuplicateRuleIdException: KnowledgeBaseException
{
/// <summary>
/// Initializes new instance of the <see cref="DuplicateRuleIdException"/> class.
/// </summary>
/// <param name="ruleId">Rule id.</param>
public DuplicateRuleIdException(string ruleId) :
base(null,"DuplicateRuleIdException",ruleId)
{
}
}
/// <summary>
/// Represents an exception thrown if new profile is created with profile id that already exists in the Knowledge Base.
/// </summary>
[Serializable]
public sealed class DuplicateProfileIdException: KnowledgeBaseException
{
/// <summary>
/// Initializes new instance of the <see cref="DuplicateProfileIdException"/> class.
/// </summary>
/// <param name="profileId"></param>
public DuplicateProfileIdException(string profileId) :
base(null,"DuplicateProfileIdException",profileId)
{
}
}
/// <summary>
/// Represents an exception thrown if user tries to delete 'All Rules' profile.
/// </summary>
[Serializable]
public sealed class AllRulesProfileCannotBeDeletedException : KnowledgeBaseException
{
/// <summary>
/// Initializes new instance of the <see cref="AllRulesProfileCannotBeDeletedException"/> class.
/// </summary>
public AllRulesProfileCannotBeDeletedException() :
base(null,"AllRulesProfileIsReadOnlyAndCannotBeDeletedException")
{
}
}
/// <summary>
/// Represents an exception thrown if change of parent property resulted in the recusrsive relationship.
/// </summary>
[Serializable]
public sealed class RecursiveParentChildRelationshipException : KnowledgeBaseException
{
/// <summary>
/// Initializes new instance of the <see cref="RecursiveParentChildRelationshipException"/> class.
/// </summary>
public RecursiveParentChildRelationshipException() :
base(null,"RecursiveParentChildRelationshipException")
{
}
}
/// <summary>
/// Represents an exception thrown when rule name change has resulted in duplicate rule name.
/// </summary>
[Serializable]
public sealed class DuplicateRuleNameException : KnowledgeBaseException
{
/// <summary>
/// Initializes new instance of the <see cref="DuplicateRuleNameException"/> class.
/// </summary>
public DuplicateRuleNameException() : base(null,"DuplicateRuleNameException")
{
}
}
/// <summary>
/// Represents an exception thrown when profile name change has resulted in duplicate profile name.
/// </summary>
[Serializable]
public sealed class DuplicateProfileNameException : KnowledgeBaseException
{
/// <summary>
/// Initializes new instance of the <see cref="DuplicateProfileNameException"/> class.
/// </summary>
public DuplicateProfileNameException() : base(null,"DuplicateProfileNameException")
{
}
}
/// <summary>
/// Represents an exception thrown when profile name change has resulted in reserved profile name.
/// </summary>
[Serializable]
public sealed class ReservedProfileNameException : KnowledgeBaseException
{
/// <summary>
/// Initializes new instance of the <see cref="ReservedProfileNameException"/> class.
/// </summary>
/// <param name="profileName">Profile name.</param>
public ReservedProfileNameException(string profileName) : base(null,"ReservedProfileNameException",profileName)
{
}
}
}
|