JPolicy 1.0.0

Package Description

There is a newer version of this package available.
See the version list below for details.
Install-Package JPolicy -Version 1.0.0
dotnet add package JPolicy --version 1.0.0
<PackageReference Include="JPolicy" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JPolicy --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: JPolicy, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install JPolicy as a Cake Addin
#addin nuget:?package=JPolicy&version=1.0.0

// Install JPolicy as a Cake Tool
#tool nuget:?package=JPolicy&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

JPolicy

JPolicy is a dynamic error exception handler. It will allow method execuction without wrapping in the try catch.
It also includes definition of policies, just like to retry method execution when failed,
default error message display during the exception, and method to execute to get the verbose exception to display or for logging purposes.

Requirements

  • .NET Core 3.1
  • Visual Studio or VS Code

How to use:

  • Go to Tools and select Manage Nuget Packages and Search for JPolicy library
    Install-Package JPolicy -Version 1.0.0

Sample Code:

using System;
using System.Collections.Generic;

namespace JPolicy.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();

            p.JWithMultiplePolicies();

            p.JDefaultPolicy();
        }

        private void JWithMultiplePolicies()
        {
            int retryExecute = 2;

            string defaultErrorMsg = "Opps! An error occured";

            bool throwException = false;

            JPolicy.CreatePolicy(retryExecute, defaultErrorMsg, test => DisplayException(test), throwException)
                                   .Execute(context => throw new Exception("I'm Inevitable"),
                                   new Dictionary<string, object>() { { "InErrorMessage", $"name of the method/function {nameof(Program)}" } });
        }

        public void JDefaultPolicy()
        {
            JPolicy.CreatePolicy().Execute(context => throw new Exception("I'm Inevitable"),
                                    new Dictionary<string, object>() { { "InErrorMessage", $"name of the method/function {nameof(Program)}" } });

        }

        private static void DisplayException(object message)
        {
            Console.WriteLine(message);
        }
    }
}

License

License: MIT
Copyright (c) 2020 Joever Monceda

Linkedin: Joever Monceda
Medium: Joever Monceda
Twitter @_EthanHunt07
Facebook: Ethan Hunt

JPolicy

JPolicy is a dynamic error exception handler. It will allow method execuction without wrapping in the try catch.
It also includes definition of policies, just like to retry method execution when failed,
default error message display during the exception, and method to execute to get the verbose exception to display or for logging purposes.

Requirements

  • .NET Core 3.1
  • Visual Studio or VS Code

How to use:

  • Go to Tools and select Manage Nuget Packages and Search for JPolicy library
    Install-Package JPolicy -Version 1.0.0

Sample Code:

using System;
using System.Collections.Generic;

namespace JPolicy.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();

            p.JWithMultiplePolicies();

            p.JDefaultPolicy();
        }

        private void JWithMultiplePolicies()
        {
            int retryExecute = 2;

            string defaultErrorMsg = "Opps! An error occured";

            bool throwException = false;

            JPolicy.CreatePolicy(retryExecute, defaultErrorMsg, test => DisplayException(test), throwException)
                                   .Execute(context => throw new Exception("I'm Inevitable"),
                                   new Dictionary<string, object>() { { "InErrorMessage", $"name of the method/function {nameof(Program)}" } });
        }

        public void JDefaultPolicy()
        {
            JPolicy.CreatePolicy().Execute(context => throw new Exception("I'm Inevitable"),
                                    new Dictionary<string, object>() { { "InErrorMessage", $"name of the method/function {nameof(Program)}" } });

        }

        private static void DisplayException(object message)
        {
            Console.WriteLine(message);
        }
    }
}

License

License: MIT
Copyright (c) 2020 Joever Monceda

Linkedin: Joever Monceda
Medium: Joever Monceda
Twitter @_EthanHunt07
Facebook: Ethan Hunt

  • .NETCoreApp 3.1

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.1 77 5/17/2021
1.0.0 109 11/25/2020