Re: Exception handling



Hi,

May it is wise, but it is not simple, because you could face different
exceptions, which your code did not predict. You definitely could handle
part of them and do not throw user-defined exception, but just make some
steps to exit from this situation.
Regarding broken connection: you will not get exception automatically if
connection was broken for some reason. Provider does not check if connection
is broken or not until it requires to execute some statement against
database. In this case you could get different types of exception depending
on what you are trying to do. In most cases you will get SqlException.

--
Val Mazur
Microsoft MVP

http://xport.mvps.org



"Bevo" <Bevo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3404866D-7BE8-445B-9E2C-F49EACAAF917@xxxxxxxxxxxxxxxx
> In my enterprise application I'd like my DataAccess layer to be
> responsible
> for handling all database error situations and to basically throw custom
> exceptions according to whether db connection is ok or not, that is,
> cDBDownException if ok or cDBException if not ok. These two exceptions
> would
> provide all information about the original cause etc.
>
> 1. Is this a wise exception handling policy?
>
> 2. We use both Oracle and SQL Server. Which exceptions do I catch to
> ascertain that we've lost contact with the db?
>
> Kind regards.
>


.



Relevant Pages

  • Re: Please Urgent - Update Data Source Problem ???
    ... You are eating exceptions all over the place without any ... first ExecutNonQuery you are going down to the catch block and bypassing ... Also, in the end of form load, you open your connection but never close it. ... If you are using the command methods, ExecuteReader, ExecuteNonQuery, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Connection state open even without a server or database?
    ... exceptions, there is no reason why you couldn't have a single label on the ... code will have the ability to react however you want it to. ... exception the first time I *really* need the connection to the database. ... As long as the connection string you've passed to the connection's ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: could not connect to itunes store
    ... *doesn't* have 'No Exceptions' checked, click on the 'Exceptions' tab at ... I have Zone Labs on my PC and the windows firewall turned off. ... Is there a port for access to Itunes store and updates? ... Connection attempt to Apple web site was unsuccessful. ...
    (uk.comp.sys.mac)
  • RE: Problem with database connectivity performance
    ... generate error messages, ADO.NET exceptions. ... If we use connection pooling we ... If we turn off connection pooling we are getting the following exception ... Before we turned off recycling of the application pool we hade another ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Problem with database connectivity performance
    ... can you confirm that only one pool is getting created ... ... generate error messages, ADO.NET exceptions. ... If we use connection pooling we ... If we turn off connection pooling we are getting the following exception ...
    (microsoft.public.dotnet.framework.performance)