I am using custom exception for my application developing in MVC. I am using below link to use understand how can I handle custom exception.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace epay.Services.ExceptionClasses
{
public class InvalidInputException : Exception
{
public InvalidInputException()
{
}
public InvalidInputException(string message) : base(message)
{
}
public InvalidInputException(string message, Exception inner) : base(message, inner)
{
}
}
}
But I am completely confused how to use the these constructor which have message and inner exception as a parameter.
I have code in controller like below...
[HttpPost]
public ActionResult Create(PartyVM PartyVM)
{
try
{
PartyService partyService = new PartyService();
var i = partyService.Insert(PartyVM);
return RedirectToAction("SaveData", PartyVM);
}
catch (InvalidInputExceptione e)
{
CommonMethod commonMethod = new CommonMethod();
PartyVM.AccountTypes = commonMethod.GetAccountTypes();
TempData["error"] = e.Message.ToString() + "Error Message";
return View("Create", PartyVM);
}
}