Abstract base class for exception handling that provides a generic error code. The library will be used in whole RaGae namespace.
To install ExceptionLib it is possible to download library [zip | gzip] or install it via nuget.
PM> Install-Package RaGae.Exception
After adding/installing the ExceptionLib in a project it can be used for personal exception classes. Information how to handle a project with ExceptionLib can be found in Wiki.
using System;
using RaGae.ExceptionLib;
namespace Project
{
public enum ErrorCode
{
OK,
ERROR,
TEST
}
public class ProjectException : BaseException<ErrorCode>
{
public ProjectException(ErrorCode errorCode) : base(errorCode) { }
public ProjectException(ErrorCode errorCode, string message) : base(errorCode, message) { }
public override string ErrorMessage()
{
switch (base.ErrorCode)
{
case ErrorCode.OK:
return "TILT: Should not be reached!";
case ErrorCode.ERROR:
return $"There was an error with {base.Message}!";
default:
return string.Empty;
}
}
}
}
R. GÄCHTER