Handles and logs the errors & exceptions.