Bit TodoTemplate provides features to handle all of the exceptions occurring in different locations.
Server-Side exception handling
- known and unknown exception: In development When an error occurred if this error is known or unknown, details of the error returned, but in test and production for unknown error details of the error not returned from server.
- known exception inhrites KnownException class
- Unknown exception inhrites UnknownException class
- RestException: It's a class that has an HTTP Response StatusCode that you to perform a response with status code.
Client-Side exception handling
When an error is raised in App(android, IOS) maybe cause crash app. for avoiding app crash; Bit provides some mechanism for error handling.
- inheriting AppComponentBase in razor pages.
- Instead of initializing your components in the OnInitializedAsync method, override the OnInitAsync method of the AppComponentBase class.
- Use WrapHandle method instead of direct calling events such as OnClick in the Razor components.
- Use try-catch block in asyn-avoid method and call StatehasChanged method to handle unexpected errors.