exception

"Parameter is not valid." when using saving bitmap

Hi Im trying to save a bitmap jpg format with a specified encoding quality. However im getting an exception ("Parameter is not valid.") when calling the save method. If i leave out the two last parameters in the bmp.save it works fine. EncoderParameters eps = new EncoderParameters(1); eps.Param[0] = new EncoderParameter...

How do I find out what exception was thrown in the Xcode debugger (for iPhone)?

I'm learning iPhone programming from Erica Sadun's The iPhone Developer's Cookbook. When I run the app I created by following the steps in the Temperature Conversion Example starting on page 81 in the simulator, it terminates due to an uncaught exception. (See http://groups.google.com/group/iphonesdk/browse_frm/thread/6f44a90fdb8da28a?...

Why wasn't the Java "throws" clause (in method declaration) included in C#?

Why wasn't the Java "throws" clause (in method declaration) included in C#? ...

Expect exceptions in nUnit without the ExpectedException attribute

Hi, I have methods with more than one parameter that are guarded against bad input by throwing ArgumentNullExceptions and ArgumentExceptions whenever any parameter is null. So there are two obvious ways to test this: One test per Parameter using the [ExpectedException] attribute One test for all parameters using multiple try{} catch b...

Dispatching exceptions in C++

How should exceptions be dispatched so that error handling and diagnostics can be handled in a centralized, user-friendly manner? For example: A DataHW class handles communication with some data acquisition hardware. The DataHW class may throw exceptions based on a number of possible errors: intermittent signal, no signal, CRC failure...

Starting Firefox using Process.Start: Firefox not starting when you set Usename and Password

Hi there. When I try to start Firefox using Process.Start and ProcessStartInfo (.NET) everything seems to work fine. But when I specify a username and password of another account (a member of Users), nothing seems to happen. The same code works fine with Calc.exe or IE. This is weird. Any ideas? Here is the code: System.Diagnostics.Pr...

How to deal with exceptions

My technical lead insists on this exception mechanism: try { DoSth(); } catch (OurException) { throw; } catch (Exception ex) { Util.Log(ex.Message, "1242"); // 1242 is unique to this catch block throw new OurException(ex); } 1242 here is an identifier of the catch method which we handle an exception other than OurExcep...

In C#, how can I serialize System.Exception? (.Net CF 2.0)

I want to write an Exception to an MS Message Queue. When I attempt it I get an exception. So I tried simplifying it by using the XmlSerializer which still raises an exception, but it gave me a bit more info: {"There was an error reflecting type 'System.Exception'."} with InnerException: {"Cannot serialize member System.Ex...

Finally in C++

Is this a good way to implement a Finally-like behavior in standard C++? (Without special pointers) class Exception : public Exception { public: virtual bool isException() { return true; } }; class NoException : public Exception { public: bool isException() { return false; } }; Object *myObject = 0; try { // OBJECT CREATIO...

Oracle: How can I programmatically arrange to have my current connection killed?

For testing exception handling in the case of a broken connection it is useful to be able to programmatically request the database to kill a connection. What's the best way to do that? ...

When is it OK to throw an exception from a destructor in C++?

I know the rule is to NEVER throw one during a destructor, and I understand why. I would not dare do it. But even the C++ Faq Lite says that this rule is good 99% of the time. What is the other 1% that they fail to delve into? Link to the C++ Faq Lite bullet point on throwing from ~(): ...

Django + FastCGI - randomly raising OperationalError

I'm running a Django application. Had it under Apache + mod_python before, and it was all OK. Switched to Lighttpd + FastCGI. Now I randomly get the following exception (neither the place nor the time where it appears seem to be predictable). Since it's random, and it appears only after switching to FastCGI, I assume it has something to ...

Exceptions from DLL/Shared libs

Suppose you are developing a library with classes to be exported through a DLL (on Windows, or similar shared-library like Linux ELF shared libs). Member functions on those classes throw exceptions either from the standard library or library defined exceptions. It is totally safe to code in DLLs to throw exceptions to the modules that m...

Cause of an unexpected behaviour using JUnit 4's expected exception mechanism?

I am trying to test that a particular method throws an expected exception from a method. As per JUnit4 documentation and this answer I wrote the test as: @Test(expected=CannotUndoException.class) public void testUndoThrowsCannotUndoException() { // code to initialise 'command' command.undo(); } However, this code fails t...

Quick Java question: Which Exception should I use?

Let's assume I'm a complete lazy bum and I don't want to invest the several dozen keystrokes needed for my own Exception class (it's not utterly important which gets used, really). However, to pretend I'm following good practices here, I want a pre-existing one that best fits my situation. Problem: I need to throw an exception when my ...

InvalidCastException: RPC_E_CANTCALLOUT_ININPUTSYNCCALL

I'm building an application in C# that has a static class which initiate a COM class and handles some event handlers of another class that hooks keyboard. When I call a method of the COM class from a button event handler in my WPF window, the method works without any problems but when I call it in one of the event callbacks within my sta...

How often do you check for an exception in a C++ new instruction?

I just started reading Effective C++ today and got to the point where the author talks about the operator new. The book explains very well how you can catch (with various degrees of elegance) the std::bad_alloc exception that the operator new can raise if you run out of memory. My question is: How often do you check for the case when t...

What Exception should be thrown from Propery Set?

In .NET, what type of exception should be thrown if someone passes an illegal value to the set { } part of a property? Example: public string Provider { get { return _provider; } set { if (String.IsNullOrEmpty(value)) throw new Exception("Provider cannot be null or empty."); //what type of exception should be thrown...

Best error names, failures or exceptions.

I was thinking about a name for a new blog and wanted to name it after a computer error of some description (partly inspired by this site). So I want to know some people favorites. I remember at a job I had "Catastrophic failure" was used a lot as an error message, to the users as well! Please give me some inspiration. There is a 99% ...

Handling unhandled exceptions problem.

I wanted to set some handler for all the unexpected exceptions that I might not have caught inside my code. In Program.Main() I used the following code: AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ErrorHandler.HandleException); But it didn't work as I expected. When I started the application in...