Exception handling


bit project templates provide 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 inherits KnownException class
    • Unknown exception inherits 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 async void method and call StateHasChanged method to handle unexpected errors.