AccountGo / accountgo

Accounting System built in ASP.NET DotNetCore, ReactJS, MobX. Don't forget to click STAR if you like this project.
http://accountgo.net
MIT License
386 stars 313 forks source link

Error and Exception Handling #21

Open codemvp opened 8 years ago

codemvp commented 8 years ago

Open for suggestion on what best logging framework to use. NLog? Log4Net?, etc.

bahmani00 commented 8 years ago

I added Glimpse.Elmah plugin so no need to do any other plugin http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForASPNETAndMVCToo.aspx

"Once ELMAH has been dropped into a running web application and configured appropriately, you get the following facilites without changing a single line of your code:

Logging of nearly all unhandled exceptions. A web page to remotely view the entire log of recoded exceptions. A web page to remotely view the full details of any one logged exception. In many cases, you can review the original yellow screen of death that ASP.NET generated for a given exception, even with customErrors mode turned off. An e-mail notification of each error at the time it occurs. An RSS feed of the last 15 errors from the log. A number of backing storage implementations for the log, including in-memory, Microsoft SQL Server and several contributed by the community."

to test, just raise and exception like http://localhost/AccountGo/itmsssss/1 and then go to http://localhost/AccountGo/elmah.axd

cheers

codemvp commented 8 years ago

Hi Dan,

Thanks for your feedback. ELMAH is real good in handling all unhandled exceptions. However, for the error that we catch, we also want to have a single location to display the error, waring, information or fatal and probably log them in the database in some instances.

Something like this image

A section just below the menu will show the error, and an "x" on the right side to close the message.

IrfanSamad commented 7 years ago

Dear codemvp, Hope you are doing well. how to incorporate this in the AccountGo. for Save, Edit and Error messages?

codejmsaints commented 5 years ago

You can add a Helper and implement the IExceptionFilter interface where its function is will run after an action has thrown an Exception. Log4Net is fine, you just need to have a design pattern to handle your exceptions.

mvperez commented 5 years ago

Yes. @codejmsaints agree.

codejmsaints commented 5 years ago

@marvinvperez ,

Have you guys implemented the IExceptionFilter? Do you guys already have the workflow on the Saving, Editing or even avoiding the Yellow Screen of Death when retrieving a data?

If not i would love to PR and to coordinate with you guys.

codemvp commented 5 years ago

Probably will wait your PR. I think on the controller side it would be straight forward. Displaying the message as in the screenshot is another thing. I think ths exception filter would be on the api? The api would return the error.

On Tue, Nov 27, 2018, 1:11 PM codejmsaints <notifications@github.com wrote:

Have you guys implemented the IExceptionFilter? Do you guys already have the workflow on the Saving, Editing or even avoiding the Yellow Screen of Death when retrieving a data?

If not i would love to PR and to coordinate with you guys.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AccountGo/accountgo/issues/21#issuecomment-441938292, or mute the thread https://github.com/notifications/unsubscribe-auth/AKMkY5UgCBgHutYO8xYq1BnJWhUxdtiYks5uzNepgaJpZM4G__gt .

codejmsaints commented 5 years ago

Sorry i found out that my suggestion above is not useful in .Net Core, however i found a solution that you need to add a middleware to have a Global Error Handling and register it in your start up.

I first add an extension for the IApplicationBuilder image

Then the created extension should register in Startup.cs image

So everytime there's an exception, .net core automatically pass through in that extension: image

as you can see the status code is not implemented as stated in the above screenshot.

codemvp commented 5 years ago

Can we add this to the infrastructure layer so that can be use by both webapp and api?

On Tue, Nov 27, 2018, 4:49 PM codejmsaints <notifications@github.com wrote:

Sorry i found out that my suggestion above is not useful in .Net Core, however i found a solution that you need to add a middleware to have a Global Error Handling and register it in your start up.

I first add an extension for the IApplicationBuilder [image: image] https://user-images.githubusercontent.com/38581906/49072634-9a5cde00-f26b-11e8-9113-1b9ca3da7011.png

Then the created extension should register in Startup.cs [image: image] https://user-images.githubusercontent.com/38581906/49072611-8c0ec200-f26b-11e8-8c87-cc20f3629925.png

So everytime there's an exception, .net core automatically pass through in that extension: [image: image] https://user-images.githubusercontent.com/38581906/49073125-af863c80-f26c-11e8-9995-d33347538fc4.png

as you can see the status code is not implemented as stated in the above screenshot.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AccountGo/accountgo/issues/21#issuecomment-441995285, or mute the thread https://github.com/notifications/unsubscribe-auth/AKMkY6sHkKsDZSudy8YBwpdzaGtmU0TIks5uzQq6gaJpZM4G__gt .

codejmsaints commented 5 years ago

Yes it applies to both, because we made an extension for IApplicationBuilder

codemvp commented 5 years ago

That's great! On the web ui part, the next question is how to add a common place to display the message.

On Tue, Nov 27, 2018, 5:14 PM codejmsaints <notifications@github.com wrote:

Yes it applies to both, because we made an extension for IApplicationBuilder

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AccountGo/accountgo/issues/21#issuecomment-442003345, or mute the thread https://github.com/notifications/unsubscribe-auth/AKMkY5stS2Y1eLKRzITkFEYGyXdRO1R9ks5uzRCSgaJpZM4G__gt .

codejmsaints commented 5 years ago

I believe its not possible to have a common ajax callback in the UI part, you just need to implement in each of your ajax call, like for example on React, i think there's a Axios if im not mistaken where its a promise based http client, in its callback you can specify the status code and return the appropriate error/message.

codemvp commented 5 years ago

3 things I would like to see here.

  1. A section below to display the messages as shown in the picture. I have that proptotype more than 3 years ago. Unfortunately, I couldn't find the prototype anymore. I agree we can easily do this in react as a component. But the site is not pure reactjs site. In _layout.cshtml we can position a div for displaying message. If the page has reactjs such add order page, I still believe we can use the div message section.
  2. The api will return a result and contain the statuscode and the error message if the statua code is not 200.
  3. In web ui controllers, the exception middleware will fire if theres an exception, and the ui will display the message. It's not only the exception but the a model error as well e.g. 'Quantity is missing'

On Tue, Nov 27, 2018, 5:34 PM codejmsaints <notifications@github.com wrote:

I believe its not possible to have a common ajax callback in the UI part, you just need to implement in each of your ajax call, like for example on React, i think there's a Axios if im not mistaken where its a promise based http client, in its callback you can specify the status code and return the appropriate error/message.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AccountGo/accountgo/issues/21#issuecomment-442009587, or mute the thread https://github.com/notifications/unsubscribe-auth/AKMkY3xHjzp3MU-86PlrigmxXe7xnv0Pks5uzRUhgaJpZM4G__gt .

codejmsaints commented 5 years ago

I think you can add a something like a Notification that it pops up when there's an error message. you can use the Kendo Notification https://demos.telerik.com/kendo-ui/notification/index

codemvp commented 5 years ago

I'm trying to avoid third party controls, tools or packages as much as possible specially if that's not fully open source and license can conflict with ours.

On Tue, Nov 27, 2018, 6:01 PM codejmsaints <notifications@github.com wrote:

I think you can add a something like a Notification that it pops up when there's an error message. you can use the Kendo Notification https://demos.telerik.com/kendo-ui/notification/index http://here

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AccountGo/accountgo/issues/21#issuecomment-442017592, or mute the thread https://github.com/notifications/unsubscribe-auth/AKMkY_VKDLGDNWJcIoaN0zxpRc03zlfcks5uzRuMgaJpZM4G__gt .

codejmsaints commented 5 years ago

this Kendo components has a lot of usage, we can use this in reports, graphing for the dashboard/forecast

mvperez commented 5 years ago

True Kendo has 40+ components can be use on free license. When you started using it, you will realize that what you want more is on the paid version. We cannot add something in the core code base that has potentially rely on NOT fully open source that we cannot support. The free version of Kendo has no support.

codejmsaints commented 5 years ago

agree, i think on the displaying of message like a notification, your designer can work on that one.