error-handling

Reducing duplicate error handling code in C#?

I've never been completely happy with the way exception handling works, there's a lot exceptions and try/catch brings to the table (stack unwinding, etc.), but it seems to break a lot of the OO model in the process. Anyway, here's the problem: Let's say you have some class which wraps or includes networked file IO operations (e.g. read...

Global Exception Handling for winforms control

When working on ASP.NET 1.1 projects I always used the Global.asax to catch all errors. I'm looking for a similar way to catch all exceptions in a WinForms user control which ends up being a hosted IE control. What is the proper way to go about doing something like this? ...

Using unhandled exceptions instead of Contains()?

Imagine an object you are working with has a collection of other objects associated with it, for example the Controls collection on a WinForm. You want to check for a certain object in the collection, but the collection doesn't have a Contains() method. There are several ways of dealing with this. Implement your own Contains() method...

How do you log errors (Exceptions) in your ASP.NET apps?

Hi, I'm looking for the best way to log errors in an ASP.NET application. I want to be able to receive emails when errors occurs in my application, with detailed information about the Exception and the current Request. In my company we used to have our own ErrorMailer, catching everything in the Global.asax Application_Error. It was "Ok...

Is there a method for handling errors from COM objects in RDML?

Is there a method for handling errors from COM objects in RDML? For instance, when calling Word VBA methods like PasteSpecial, an error is returned and the LANSA application crashes. I cannot find anything in the documentation to allow handling of these errors. Actually, error handling in general is a weak-point for LANSA and RDML, but ...

What's the best way to report errors from a SharePoint workflow?

I have a custom action in a workflow and would like to report an error to the user when something goes wrong. What's the best way of doing that? UPD: Ideally I would like to put the workflow in the error state and log a message to the workflow log. That doesn't seem possible. What's the closest I can get to it? I want to a reusable s...

How do I log uncaught exceptions in PHP?

I've found out how to convert errors into exceptions, and I display them nicely if they aren't caught, but I don't know how to log them in a useful way. Simply writing them to a file won't be useful, will it? And would you risk accessing a database, when you don't know what caused the exception yet? ...

.NET - Throwing Exceptions best practices

What are the best practices to consider when catching exceptions, and re-throwing them. I want to make sure that the Exception object's InnerException and stack trace are preserved. Is there a difference between the following code blocks in how they handle this? try { //some code } catch (Exception ex) { throw ex; } //...... t...

How to catch SQLServer timeout exceptions

I need to specifically catch SQL server timeout exceptions so that they can be handled differently. I know I could catch the SqlException and then check if the message string Contains "Timeout" but was wondering if there is a better way to do it? try { //some code } catch (SqlException ex) { if (ex.Message.Contains("Timeout"))...

How to Catch an exception in a using block with .NET 2.0?

I'm trying to leverage the using block more and more these days when I have an object that implements IDisposable but one thing I have not figured out is how to catch an exception as I would in a normal try/catch/finally ... any code samples to point me in the right direction? Edit: The question was modified after reading through the re...

Error handling / error logging in C++ for library/app combo

I've encountered the following problem pattern frequently over the years: I'm writing complex code for a package comprised of a standalone application and also a library version of the core that people can use from inside other apps. Both our own app and presumably ones that users create with the core library are likely to be run both ...

How to catch unhandled exceptions when using .NET Remoting

I want to catch all unhandled exceptions thrown in a remote object on the server and log them there before I translate them into some custom exception so that specific exceptions do not cross the client/server boundary. I think I have to use a custom channel sync, but can anyone confirm this and/or have any other advice to give? ...

Can I detect and handle MySQL Warnings with PHP?

I'm dealing with a MySQL table that defines the JobName column as UNIQUE. If somebody tries to save a new Job to the database using a JobName that is already in the database, MySQL throws a warning. I would like to be able to detect this warning, just like an error, in my PHP script and deal with it appropriately. Ideally I would like...

How do you manage your app when the database goes offline?

Take a .Net Winforms App.. mix in a flakey wireless network connection, stir with a few users who like to simply pull the blue plug out occasionally and for good measure, add a Systems Admin that decides to reboot the SQL server box without warning now and again just to keep everyone on their toes. What are the suggestions and strategie...

Print stack trace information from C#

As part of some error handling in our product, we'd like to dump some stack trace information. However, we experience that many users will simply take a screenshot of the error message dialog instead of sending us a copy of the full report available from the program, and thus I'd like to make some minimal stack trace information availabl...

Php function argument error suppression, empty() isset() emulation

I'm pretty sure the answer to this question is no, but in case there's some PHP guru is it possible to write a function in a way where invalid arguments or non existent variables can be passed in and php will not error without the use of '@' Much like empty and isset do. You can pass in a variable you just made up and it won't error. ...

How to capture crash logs in Java

I'm working on a cross platform application in Java which currently works nicely on Windows, Linux and MacOS X. I'm trying to work out a nice way to do detection (and handling) of 'crashes'. Is there an easy, cross-platform way to detect 'crashes' in Java and to do something in response? I guess by 'crashes' I mean uncaught exceptions. ...

Error handling in BASH

What is your favorite method to handle errors in BASH? The best example of handling errors in BASH I have found on the web was written by William Shotts, Jr at http://www.linuxcommand.org. William Shotts, Jr suggests using the following function for error handling in BASH: #!/bin/bash # A slicker error handling routine # I put a va...

Sql Server 2005 error handling - inner exception

In C# you can get the original error and trace the execution path (stack trace) using the inner exception that is passed up. I would like to know how this can be achieved using the error handling try/catch in sql server 2005 when an error occurs in a stored procedure nested 2 or 3 levels deep. I am hoping that functions like ERROR_ME...

How to catch all exceptions in Flex?

When I run a Flex application in the debug flash player I get an exception pop up as soon as something unexpected happened. However when a customer uses the application he does not use the debug flash player. In this case he does not get an exception pop up, but he UI is not working. So for supportability reasons, I would like to catch ...