Handling exceptions with MVC + Postsharp. This is my project architecture
MVC Project ->>> Business Layer ->>> DataLayer
MVC Project (Added custom filter in Global file and created a Base Controller to catch exceptions.)
Business Layer (middleware)
DataLayer (connects to Postgres database server and fetches data.)
In the DataLayer I have added PostSharp to handle exceptions from the database side and logged/email using NLog. Now from here I want to tell MVC Exception pipeline to display proper message to User that some exception has occured. So I use
args.FlowBehavior = FlowBehavior.ThrowException;
Now I catching this exception at MVC OnException method.
ISSUE : I am also logging and sending email on exception at MVC Exception method as well for any exceptions occuring at MVC side.
Now the problem is I have already logged and sent email for the exeption which was handled by Postsharp and now when it reaches at MVC Exception handler will do that again.
How can I know at MVC that the exception has already been logged. Can I do anything at Postsharp end like send some arguments in that which I can check at MVC Exception handler.
Please suggest a solution or guide to resolve this issue