exception

C++ : handle resources if constructors may throw exceptions (Reference to FAQ 17.4]

Hi, Thanks for all the response. I reformatted my question to understand the state of the member pointer after the containg class constructor throws an exception Again my example class :) class Foo { public: Foo() { int error = 0; p = new Fred; throw error; // Force throw , trying to understand what w...

Seeing WHICH object reference caused a NullReferenceException

When debugging C# with Visual Studio, is it possible to see WHICH object reference on a given line of code caused a NullReferenceException? I have what seems like an odd situation where, occassionally, when running a debug build of an application from Visual Studio, I will get a NullReferenceException at a certain line. Visual Studio w...

Detect compiler with #ifdef

I'm trying to build a small code that works across multiple platforms and compilers. I use assertions, most of which can be turned off, but when compiling with PGI's pgicpp using -mp for OpenMP support, it automatically uses the --no_exceptions option: everywhere in my code with a "throw" statement generates a fatal compiler error. ("sup...

C# Index was outside the bounds of the array

Hi all, I'm hoping someone can help with an exception I've inherited. Basically I'm writing the rows in a datagrid to a text file. Which works fine apart from when the row is hidden, when the row is hidden the exception "Index was outside the bounds of the array" is thrown at the line highlighted below. Thanks for any help. DataRow dr;...

How do I let Delphi know I've already handled an exception?

I've set Application.OnException to a custom exception handler so that I can log crashes and give an option to exit. However, I'm now finding that this runs even on exceptions that I've already handled, for instance, exceptions that come up when validating number inputs. Is there a way to have the custom exception handler only run on unh...

How can I use Sun's JAI-ImageIO with an Eclipse BIRT plugin?

I'm trying to write an extension (plug-in) for Eclipse BIRT reporting. It involves extracting images from a file according to database entries and displaying them. I am using Sun's JAI-ImageIO to access TIFF file data and convert to PNG for display within the report. My code complies, but throws a NoClassDefFound runtime exception: SEV...

Python: how can I handle any unhandled exception in an alternative way?

Normally unhandled exceptions go to the stdout (or stderr?), I am building an app where I want to pass this info to the GUI before shutting down and display it to the user and, at the same time I want to write it to a log file. So, I need an str with the full text of the exception. How can I do this? ...

Python Multiprocessing exit error

Hey everyone I am seeing this when I press Ctrl-C to exit my app Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/lib/python2.6/multiprocessing/util.py", line 269, in _exit_function p.join() File "/usr/lib/pyt...

Casting objects in Java

I saw a few topics on SO about this but none really answered my question so here it is: String s = "a string"; Object o = s; s = String(o); // EDIT this line was wrong s = (String)o; // EDIT Corrected line Now this compiles fine but throws a ClassCastException. The only thing is that I thought there was some way to make this work. i...

Recovering from a CommunicationObjectFaultedException in WCF

I have a client app that tries every 10 seconds to send a message over a WCF web service. This client app will be on a computer on board a ship, which we know will have spotty internet connectivity. I would like for the app to try to send data via the service, and if it can't, to queue up the messages until it can send them through the...

"Cursor is closed" error - when trying to execute an Oracle SP using JDBC

The Oracle version of our database is 10g. The stored procedure selects all the elements in a table and returns a REF CURSOR type as follows: create or replace PROCEDURE S_S_TEST( test_OUT OUT OAS_TYPES.REFCURSOR ) AS BEGIN OPEN test_OUT FOR SELECT * FROM table_p; CLOSE test_OUT; END S_S_TEST; When this sto...

How to catch an exception in WinForms when there are many actions that are asynchronous operations

Hi: I have many asynchronous operations in different class. When error,it will throw special exception which is inherited from System.Exception. In some form,I wanna catch it by messageBox. The function "Application.ThreadException" cannot catch it. In other word,I cannot catch all the exceptions by the function when there is some ...

How should communication be done n-Tier applications between layers?

Recently I have been debating on the best way to handle communication up the chain in n-tier architecture. Currently the methods I am doing is throwing and handling exceptions between layers for errors, and using events/delegates for other communication (to update progress bars and such). Are these the best way or is there another metho...

Convert Python exception information to string for logging

I try logging exceptions in Python 2.5, but I can't do it. All formatting functions do something else than what I want. I came up with this: def logexception(type, value, traceback): print traceback.format_exception(type, value, traceback) sys.excepthook = logexception but it bails out with an argument error when called, though ac...

.Net equivalent to Java's AssertionError

In Java, I will occasionally throw an AssertionError directly, to assert that a particular line will not be reached. An example of this would be to assert that the default case in a switch statement cannot be reached (see this JavaSpecialists page for an example). I would like to use a similar mechanism in .Net. Is there an equivalent ...

How to check if a custom exception is raised in a Ruby app?

I have a test class: require File.dirname(__FILE__) + '/../car.rb' class CarTest < Test::Unit::TestCase def test_set_color assert_raise InvalidColorEntry "Exception not raised for invalid color" do Car.set_color("not a color") end end end InvalidColorEntry is an exception class that I placed in the car.rb f...

What kind of exception to throw?

Hello. This question might sound a bit stupid but here it goes. I have two functions that can be called at any moment. The first function takes a snapshot, and the second one analyses the data taken from that snapshot. Of course if the user tries to analyse the snapshot before taking it, my application should throw an exception. I know ...

Is there a generally accepted idiom for indicating C++ code can throw exceptions?

I have seen problems when using C++ code that, unexpectedly to the caller, throws an exception. It's not always possible or practical to read every line of a module that you are using to see if it throws exceptions and if so, what type of exception. Are there established idioms or "best practices" that exist for dealing with this proble...

Problem in accessing/writing to EventLog

I'm working with some old code (and frankly I don't know half of what it does) trying to move it over to IIS7. One of the problems I see is that I get this error: [SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.] If I go manually to HKEY_LOCAL_MACHINE\SYSTEM\...

Most common checked and unchecked Java Exceptions?

As far as I understand, there is no way to find out which Exceptions a method throws without looking up the API docs one-by-one. Since that is no option, I'd like to reverse the research and ask you which are the most common Exceptions and RuntimeExceptions you've come across when dealing with Casting Arrays Vector, ArrayList, HashMap...