exception-handling

boost exceptions

Do all boost exceptions derive from std::exception? If not do they all derive from some base exception class? ...

To handle exception with every form or just at main

I have a question about handling exception. I have a Winform that uses a webservice proxy on each form for data retrieval and processing. Here is where I really got confused and having a long time deciding which is better. A. For each call in the web service do a try catch to display the error message and allow the user to re try the pr...

Calling Console.WriteLine(ex.Message) to prevent warning message

We usually catch exception in the upper level of a code like the GUI (forms). But I usually have this kind of code try { } catch(Exception ex) { Console.WriteLine(ex.Message); MessageBox.Show("Application has encountered error...."); } I could just catch(Exception) without the identifier because I do not need the message on runti...

When is a C++ terminate handler the Right Thing(TM)?

The C++ standard provides the std::set_terminate function which lets you specify what function std::terminate should actually call. std::terminate should only get called in dire circumstances, and sure enough the situations the standard describes for when it's called are dire (e.g. an uncaught exception). When std::terminate does get cal...

ELMAH and Exception Management in ASP.NET MVC

I am looking at moving away from the Exception Management Application Block in the Enterprise Library for a new ASP.NET MVC site. Scott Hansleman's post(s) on ELMAH has caught my eye but I don't fully understand the approach. Typically I would suppress some exceptions (ones that are recoverable), log them in a central repository, and...

Continuing Inserts in Oracle when exception is raised

Hi, I'm working on migration of data from a legacy system into our new app(running on Oracle Database, 10gR2). As part of the migration, I'm working on a script which inserts the data into tables that are used by the app. The number of rows of data that are imported runs into thousands, and the source data is not clean (unexpected nul...

Would I want to throw an exception or an error in this PHP script?

Hi, I have a PHP script that runs database queries. Now, if a query fails, should I trigger an error or throw an exception? I noticed that if I do the latter, the script execution will stop after facing the exception. My code is as follows: if (!$this->connection[0]->query($this->query)) throw new Exception($this->connection[0]->e...

Getting IO exception for a missing resource

I am testing my code with a negative test case i.e I have removed one of the keys from the property file. In this case the code is suppose to give a missing resource message(Looger msg given in the catch block of Missing Resource excpetion),but instead it is giving a message from IO exception's catch block and the message is "IO Exceptio...

how to catch exception of MVC view?

In controller, try...catch can catch exception. How to catch exception in view? for example, a view may have code like: <%= Html.Encode(Model.MyID)%> If Model is null, you will get exception when access the view. where to catch the exception and redirect user to a error page with user-friendly error message? ...

Using Exceptions throwing in C#. Does it affect a performance?

Hi! Basically, the question is: Do the Exceptions in C# affect the performance a lot? Is it better to avoid Exceptions rethrow? If i generate an exception in my code, does it affect a performance? Sorry for the sillines of the question itself ...

How can I catch all the exceptions that will be thrown through reading and writing a file?

In Java, is there any way to get(catch) all exceptions instead of catch the exception individually? ...

Handling exceptions without try block in Python's interactive shell

See the title of this question. I want to play with the exception raised in the last command. _ didn't help me. Is there anything like that? ...

Returning a value on exception

Why does this code not compile? It gives me the error: not all code paths return a value Code: public bool isUserProfileHashed(string username) { bool isHashed = false; MembershipUser u = null; u = Membership.GetUser(username); if (u != null) { try { u.GetPassword(); ...

What is the simplest RTTI implementation for C++?

I'm trying to implement exception handling for an embedded OS and I'm stuck at how to detect the type of the thrown "exception" (to select the appropriate handler). The saving and restoring context parts of the exception handling are already done, but I can't have specific handles since I can't detect the type of the thrown 'exception'....

Exception/Error handling in Objective-C (iPhone app)

I actually have two questions regarding exception/error handling in the iPhone app that I am making: The app uses Internet, but when there's no connection, the app just dies (during launch). How can I handle this to print some infomsg to the user, instead of just getting thrown back to the springboard? Can someone show me an example of...

Does try/finally ignore exceptions?

I have a situation where I want certain code to be executed no matter what happens, but I need exceptions to also be passed on up the stack to be handled later. Is the following: try { // code } finally { // code that must run } going to just ignore any exceptions, or will it pass them on up? My testing seems to show that they st...

HttpPostedFile.SaveAs error, rooted path?

I have an HttpPostedFile object, when i try saving it via SaveAs i get this exception System.Web.HttpException "The SaveAs method is configured to require a rooted path, and the path './tempUpload/4' is not rooted." Why? how do i correct it? ...

How to detect System.IO.IOException cause by existing file?

I want to create and open a file but only if it doesnt exist. I dont want to use a File.Exists because a thread by switch after it creating a file with the same name. How do i check if the exception System.IO.IOException was caused by the file existing? I prefer not to parse the error msg (even tho it can be as simple as .indexOf("exist...

How to work with unchecked exceptions?

Java has compiler checked exceptions. When I made transition to C++, I learned it doesn't feature checked exceptions. At first, I kept using exception handling, because it's a great feature. However, after a while I abandoned it, because I got into a situation every function might throw an exception. As only a small percentage of the fun...

DB2 Exception handling

The problem that I am facing is primarily on Exception Handling! When an exception occurs I want to put that data in another log table with the error message. However, in DB2 I am not able to figure out a way to retrieve the corresponding error message for the raised SQLSTATE. PS: I have a stored procedure for this migration and I am n...