Skip to content

Latest commit

 

History

History
62 lines (45 loc) · 2.09 KB

README.md

File metadata and controls

62 lines (45 loc) · 2.09 KB

Version: 1.0 Release NuGet Build Status codecov License: GPL v3

ExceptionLib

Description:

Abstract base class for exception handling that provides a generic error code. The library will be used in whole RaGae namespace.


Installation

To install ExceptionLib it is possible to download library [zip | gzip] or install it via nuget.

PM> Install-Package RaGae.Exception

Usage

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