Exceptions.cs :  » Development » devAdvantage » AnticipatingMinds » Genesis » KnowledgeManagement » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Development » devAdvantage 
devAdvantage » AnticipatingMinds » Genesis » KnowledgeManagement » Exceptions.cs
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)
    {
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.