Re: catch all program errors...



you can simply add a Try/Catch Block to your main method:

try {

// what you usually do in main

} catch (Exception e) {
// your logging code
}

Whether you /should/ do that is a completely different story, since you
are then surpressing severe program errors (what does not make them
less severe, but harder to detect). For example the program might throw
your NullPointerException in the middle of some transaction with the
user; then the exception is caught, and the user might never notice
that the transaction was not finished. The application might be in an
undefined error state then.

I would think about the risks first.

/philipp

tiewknvc9 wrote:
Im trying to find a quick way to catch all of my programs errors. These
would be the last remaining errors that are not currently caught in my
application,

for instance it would be a nullpointer exception - one that I never
expected to occur, so it was not caught. What I would like to do is to
catch any and all exceptions and log them in some way so that I can
update the program, and alert the user to the fact that an error had
occurred. The later I get, the catching all uncaught errors I am lost
with.

Any advice?

Thanks

.



Relevant Pages

  • BEGIN TRANSACTION problem
    ... there was no BEGIN TRANSACTION. ... The test prior to the exception is the first to execute the parent ... The is the exception the unit test is expecting. ... Rollback statement faile with "The ROLLBACK TRANSACTION request has no ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: HELP on New request is not allowed to start because [1264822]
    ... allowed to start because it should come with valid transaction descriptor. ... System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean ... TRXOrders.CLogin.GetTradexUserIDFromQube(String QubeUserID, String GroupCode) ... This error always occurs when we issue the command to SQL Server. ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: HELP on New request is not allowed to start because [1264822]
    ... "Jeff Glenn" wrote: ... We have posted a simple code reproducing the behavior to Microsoft. ... application doen't raise any exception during a distributed transaction. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Behavior of Connection.commit()
    ... You have to remember that Sql Server does not understand the concept of a ... we have to fake this with "Begin transaction" ... exception you probably have data corruption. ... getting this error with our driver and filed it as a bug. ...
    (microsoft.public.sqlserver.jdbcdriver)
  • RE: HELP on New request is not allowed to start because [1264822]
    ... Do you have a link to the bug? ... application doen't raise any exception during a distributed transaction. ... This error always occurs when we issue the command to SQL Server. ...
    (microsoft.public.dotnet.framework.adonet)