A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_URI::$config is deprecated
Filename: core/URI.php
Line Number: 101
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Router::$uri is deprecated
Filename: core/Router.php
Line Number: 127
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$benchmark is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$hooks is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$config is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$log is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$utf8 is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$uri is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$exceptions is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$router is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$output is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$security is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$input is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$lang is deprecated
Filename: core/Controller.php
Line Number: 82
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$db is deprecated
Filename: core/Loader.php
Line Number: 396
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_DB_mysqli_driver::$failover is deprecated
Filename: database/DB_driver.php
Line Number: 371
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: Trying to access array offset on true
Filename: libraries/Email.php
Line Number: 978
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$email is deprecated
Filename: core/Loader.php
Line Number: 1283
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 295
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 169
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 238
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 318
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Return type of CI_Session_files_driver::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 359
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 282
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_cookie_params(): Session cookie parameters cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 289
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 304
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 314
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 315
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 316
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 317
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: ini_set(): Session ini settings cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 375
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_set_save_handler(): Session save handler cannot be changed after headers have already been sent
Filename: Session/Session.php
Line Number: 110
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Warning
Message: session_start(): Session cannot be started after headers have already been sent
Filename: Session/Session.php
Line Number: 143
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$session is deprecated
Filename: core/Loader.php
Line Number: 1283
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property Blogs::$user_model is deprecated
Filename: core/Loader.php
Line Number: 358
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/User.php
Line: 7
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 8
Function: __construct
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$load is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$pgmodule is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$benchmark is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$hooks is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$config is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$log is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$utf8 is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$uri is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$exceptions is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$router is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$output is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$security is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$input is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$lang is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$db is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$email is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$session is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: 8192
Message: Creation of dynamic property CI_Loader::$user_model is deprecated
Filename: core/Loader.php
Line Number: 931
Backtrace:
File: /home1/biognosy/skmlhometuitions.in/application/controllers/Blogs.php
Line: 234
Function: view
File: /home1/biognosy/skmlhometuitions.in/index.php
Line: 315
Function: require_once
Exception Handling in C# | Post Details - SKML Home Tuitions
Exception Handling in C#
Exception Handling is all about handling exceptions and is one of the most important topic in C#.
In this blog, I will explain about Exceptions and how to handle them using the different keywords we have in C# and finally, we will see some examples for the same.
Exception – What is it?
An exception can be termed as any error or an issue in our application code, which can change the execution flow to some different part of the program or might terminate the program itself.
All exceptions are defined inside a namespace System.Exception in C#. Some common exceptions include:
IndexOutOfRangeException, ArgumentOutOfRangeException, InvalidOperationException
C# also provides us with an option to create custom exceptions of our choice.
In order to avoid the program changing the execution flow or prevent its termination in an unexpected way, we go for handling of exceptions using Exception Handling mechanism in C#.
Exception Handling – How it is done ?
C# has provided us with some keywords to implement exception handling, which are try , catch finally and throw keywords.
try-catch are basically the application code blocks. By keeping the code inside try block, we make it code safe by verifying it since the catch block will catch the error occurred or raised based on the type of exception defined in the catch block.
Whenever some error occurs inside the code which is placed inside try block, the .NET runtime will check the catch block to find out if the exception type which is defined in the catch statement is of the same type of which the error is thrown or is a generic base class of exception which is being raised. Then, it will execute the catch block which matches with the type of the exception that is encountered.
We can add as many catch blocks for a single try block, but we should keep in mind that the specific catch block should come first followed by others and the generic catch block for base class of exception should come last.
It is not necessary that the catch block will execute, it might happen that no error or issue is encountered in the try block. Sometimes, we might need to do some kind of cleanup maybe of resources or close some database connections, for that we use finally block. The finally block is one which executes regardless of whether the exception has occurred or not.
Sometimes, there is a situation or scenario where we want to raise an exception, in that case we go for throw keyword.
Syntax:
Below is the syntax of exception handling in C#.
try
{
// application code
}
catch (Exception ex)
{
throw new Exception("Your Message", ex);
}
finally
{
// code for cleanup
}
Examples:
Let’s see some examples of handling exceptions in C#.
Example 1: DivideByZeroException
The below program will throw a DivideByZeroException if we divide a number by zero.
using System;
namespace ExceptionHandling {
class Numbers {
int result;
Numbers() {
result = 0;
}
public void division(int a, int b) {
try {
result = a / b;
} catch (DivideByZeroException e) {
Console.WriteLine("Exception: {0}", e);
} finally {
Console.WriteLine("Result: {0}", result);
}
}
static void Main(string[] args) {
Numbers d = new Numbers();
d.division(19, 0);
Console.ReadLine();
}
}
}
Example 2: FileException – FileNotFoundException / IOException
The below program will throw a FileNotFoundException if the requested file does not exist or IOException it the runtime is not able to read the requested file. This example makes use of multiple catch blocks for a single try block.
using System;
using System.IO;
namespace ExceptionHandling
{
public class ProcessFile
{
public static string ReadTheFile(string path)
{
var data = "";
try
{
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
using (var file = new StreamReader(stream))
{
data = file.ReadToEnd();
}
}
}
catch (FileNotFoundException ex)
{
data = "Could not find the file.";
}
catch (IOException ex)
{
data = "Not able to read the content from the file.";
}
catch (Exception ex)
{
data = "Some error occurred.";
}
return data;
}
}
}
Not sure whare to join tuition right for you?
Choose the right one for you.
Get the help of the experts and find a solution that best suits your needs.
Let`s Connect