exception-handling

Exception handling in Obj-C

I have been reading about exception handling on the Apple developer docs, but I was wondering why exceptions by standard C operations are not caught? E.g. the code below still crashes the application, without catching the div by zero. Will the @try/@catch block only catch Obj-C code? @try { int i = 10 / 0; } @catch (NSException * ...

How to create custom exception handler for custom controls or extension methods.

I am creating an extension method in C# to retrieve some value from datagridview. Here if a user gives column name that doesnot exists then i want this function to throw an exception that can be handled at the place where this function will be called. How can i achieve this. public static T Value<T>(this DataGridView dgv, int RowNo,...

Imageiio can't create imageinput stream

When using imageio.imageio.read iget a can't create ImageInputStream. I have a catch exception around it so the program survives but i was wondering if theres a way to put an if statement round it that checks to see if it falied and then attempt to read it again if it did. basically asking if there is a test for exceptions? ...

Catches communication exception instead of custom fault exception - WCF

On Server I'm throwing the exception like this. catch(SqlException exception) { if (exception.Message.Contains("Custom error from stored proc")) { //Exception to be thrown when authentication fails. throw new FaultException<MyServiceFault>(new MyServiceFault { MessageText = exception.Message }); } } And on client end I'm...

Is it possible to control Visual Studio exception handling from the debugged code itself?

Dear ladies and sirs. I am wondering if it is possible to control the Visual Studio exception handling options from the code itself. For instance, I would like to turn off stopping on FCE for a certain piece of code, that generates many FCE, however, I would like it to be active for all the other code. Is it possible to do it from code?...

Static code analysis tool for detecting uncaught exceptions in a C++ code before compilation?

I'm looking for such a tool to be able to check fast if I catch all the exceptions I generate myself. Thanks! ...

Throwing a new exception while throwing an old exception

If a destructor throws in C++ during stack unwinding caused by an exception, the program terminates. (That's why destructors should never throw in C++.) Example: struct Foo { ~Foo() { throw 2; // whoops, already throwing 1 at this point, let's terminate! } }; int main() { Foo foo; throw 1; } terminate cal...

How to avoid an HttpException due to timeout

I'm working on a website powered by .NET asp/C# code. The clients require that sessions have a 25 minute timeout. However, sometimes the site is used, and a user stays connected for long periods of time (longer than 25 mins). Session_End is triggered: protected void Session_End(Object sender, EventArgs e) { Hashtable trackingInforma...

Correct Exceptions in C++

I am just learning how to handle errors in my C++ code. I wrote this example that looks for a text file called some file, and if its not found will throw an exception. #include <iostream> #include <fstream> using namespace std; int main() { int array[90]; try { ifstream file; file.open("somefile.txt"); if(!file.good()) th...

C# Throw Exception on use Assert?

I have a system where the employeeId must alway exist unless there is some underlying problem. The way I see it, is that I have two choices to check this code: 1: public void GetEmployee(Employee employee) { bool exists = EmployeeRepository.VerifyIdExists(Employee.Id); if (!exists) { throw new Exception("Id d...

protecting COM interfaces from exceptions

I have several dozen objects exposed through COM interfaces, each of which with many methods, totaling a few hundred methods. These interfaces expose business objects from my app to a scripting engine. I have been given the task of protecting every single one of these methods from exceptions being thrown (to catch them and return an er...

Eclipse - Handling Java Exceptions like in NetBeans

I recently moved from NetBeans to Eclipse and I very much miss one great feature - whenever I use method which throws some kind of exception, NetBeans alerted me and I needed to add try-catch and NetBeans automatically generated exception type for me. Is there something similiar for Eclipse? f.e. : Integer.parseInt(new String("foo")); ...

In C#, how do I know which exceptions to catch?

I've gotten in the habit of using a general catch statement and I handle those exceptions in a general manner. Is this bad practice? If so, how do I know which specific exceptions could be thrown and which ones do I catch? ...

How to handle global Exception in ASP.Net MVC 2

My base controller has this override: protected override void OnException(ExceptionContext filterContext) { // http://forums.asp.net/t/1318736.aspx if (filterContext == null) { throw new ArgumentNullException("filterContext"); } // If custom errors are disabled, we need to let the normal ASP.NET exception han...

Complex error handling

I've got a particularly ornery piece of network code. I'm using asio but that really doesn't matter for this question. I assume there is no way to unbind a socket other than closing it. The problem is that open(), bind(), and listen() can all throw a system_error. So I handled the code with a simple try/catch. The code as written in...

How to handle unhandled exception in .NET web services

I need to handle all the exceptions globally in .NET 2.0 web service (ASMX), i tried using Application_Error event in global.asax, but it's not fired in web services case, it works fine for web based applications. Any suggestions??? ...

Handling missing resources

I've just found myself in situation where I needed to handle exception I'll probably never get, so out of curiosity, let's do a small poll. Do you validate the presence of resources in your programs? I mean, those resources which are installed with your program, like icons, images and similar. Generally, if those are missing, either yo...

wcf - catch unhandled exception

Sorry about my English in WCF, Is there an event or method that catch unhandled exception? or i need to put try/catch in eny mathod Thanks ...

Why should I not wrap every block in "try"-"catch"?

I have always been of the belief that if a method can throw an exception then it is reckless not to protect this call with a meaningful try block. I just posted 'You should ALWAYS wrap calls that can throw in try, catch blocks.' to this question and was told that it was 'remarkably bad advice' - I'd like to understand why. Thanks! ...

Better exception for non-exhaustive patterns in case

Is there a way to get GHCi to produce better exception messages when it finds at runtime that a call has produced value that does not match the function's pattern matching? It currently gives the line numbers of the function which produced the non-exhaustive pattern match which though helpful at times does require a round of debugging w...