exception

Proper way to declare custom exceptions in modern Python?

What's the proper way to declare custom exception classes in modern Python? My primary goal is to follow whatever standard other exception classes have, so that (for instance) any extra string I include in the exception is printed out by whatever tool caught the exception. By "modern Python" I mean something that will run in Python 2.5 ...

Should I ignore an exception on database insert?

I have two tables, A and B and a simple table, X, that maintains a relationship between the two. X contains AID and BID as its primary key. I'm using Linq-to-Sql to insert a relationship like: public void InsertRelationship(int y, int z) { DataContext.X.InsertOnSubmit(new x { AID = y; BID = z }); } The problem is that two calls to ...

Is it possible to log the entire value of parameters in Exception traces?

When reading over my error logs I notice that long parameters (such as SQL strings) are truncated in the Exception trace. Here's an example: FR_Model.php(204): FR_Base->query('INSERT INTO pos...', Array) I'd like an easy way to echo the full parameter without having to roll my own Exception subclass. TIA. ...

Can you explain this bizarre crash in the .NET runtime?

My C# application sends me a stack trace when it throws an unhandled exception, and I'm looking at one now that I don't understand. It looks as though this can't possibly be my fault, but usually when I think that I'm subsequently proved wrong. 8-) Here's the stack trace: mscorlib caused an exception (ArgumentOutOfRangeException): sta...

Vectored exception handler and Microsoft C runtime error handling

Hi, I've recently implemented some vectored exception handling to catch errors in our software. This is especially useful as we've just converted from vc6 to vs2005. We're encountering a few problems with the use of the STL library (generally people doing things they shouldn't). I'm trying to catch these errors with my vectored exceptio...

Type initializer (static constructor) exception handling

I'm writing a WCF service in C#. Initially my implementation had a static constructor to do some one-time initialization, but some of the initialization that is being done might (temporarily) fail. It appears that static constructors are only called once, even if the first (failed) attempt threw an exception? Any subsequent attempts to ...

Why does the code crash?

Looking on the internet for C++ brainteasers, I found this example: #include <iostream> using namespace std; class A { public: A() { cout << "A::A()" << endl; } ~A() { cout << "A::~A()" << endl; throw "A::exception"; } }; class B { public: B() { cout << "B::B()" << endl; throw...

FbDataAdapter Update throwing NullReferenceException

When updating a DataTable with 1850-ish new rows to a FbDataAdapter I get a NullReferenceException during execution. Usually it succeeds in inserting around 1200 records, sometimes more, sometimes less... However when stepping through the code with the debugger, it sometimes inserts the entire recordset, no problem. I am using the Fir...

c++ Exception Class Design

What is a good design for a set of exception classes? I see all sorts of stuff around about what exception classes should and shouldn't do, but not a simple design which is easy to use and extend that does those things. The exception classes shouldn't throw exceptions, since this could lead straight to the termination of the process wi...

How can I write an exception stack trace in erlang after catching it?

Suppose I have something like this : try code_that_fails() catch _:_ -> ..... How do I print the stacktrace in the catch block? That block catches all exceptions, but I don't know how to print the stack... Can you help me? ...

Should my method throw an exception?

My PHP web application is divided into modules, and I use the data model and data mapper patterns. My mapper methods are static, and they exist specifically to interact with the database. I have the following method: ModuleMapper::getRecordCountByModuleIdAndSiteId($moduleId, $siteId) This method is only meant for a set list of module...

C# equivalent of "EXCEPTION_CONTINUE_EXECUTION" with exception filter

Hi all, Is it possible that using C# to do some exception handling with filter function and continue execution at the point where the exception occurred like C++ does? Thanks, ...

A and B, B raises exception only if A is False - conisdered a good style?

Canonical example: while foo.hasBar() && foo.getBar() != spam { do lots of stuff } foo.getBar() will raise an exception if it has no bar. However, it is guaranteed that this expression will not be evaluated unless foo has a bar. Is that considered a good programming style? ...

SQL Distinct Count with an exception

I'm trying to count how many distinct value of FLOOR there is but I don't want the value "B" to count towards the total. Here is my current code. It counts how many distinct floors there is but it includes the FLOOR "B" when there is one. SELECT COUNT(DISTINCT FLOOR) as NB_FLOORS FROM TABLE_ID The table looks something like this : ...

Nice exception handling when re-trying code

I have some test cases. The test cases rely on data which takes time to compute. To speed up testing, I've cached the data so that it doesn't have to be recomputed. I now have foo(), which looks at the cached data. I can't tell ahead of time what it will look at, as that depends a lot on the test case. If a test case fails cause it doe...

Hosting a flash app in a WindowsFormsHost in a Surface application and .CallFunction

I'm working on adding a Flash app to a Surface application. It looks to be working just fine (overlaying the Flash app with an almost transparent Surface window to catch the Contacts). However, if I want to call a Flash function in my SWF (using .CallFunction), I get a E_FAIL exception. It is suggested that a callback function in the SW...

VB.NET - SQLCommand.ExecScalar() throws unreferenced exception on Return?

I'm calling Sqlcommand.ExecScalar() - stepping through the stored proc works fine, right under RETURN @RecordNum @RecordNum correctly contains a bigint, as scoped. When I step into the RETURN.. I get an exception thrown, that visual studio does not seem to be able to capture. The stored procedure works fine when executed directly, a...

Implementing Nullable Types in Generic Interface

So in a previous question I asked about implementing a generic interface with a public class and bingo, it works. However, one of the types I'm looking to pass in is one of the built in nullable types such as: int, Guid, String, etc. Here's my Interface: public interface IOurTemplate<T, U> where T : class where U : class { ...

Stack smashing detected

I am executing my a.out file .After execution the program runs for some time then exits with the message: ** stack smashing detected : ./a.out terminated ======= Backtrace: ========= */lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)Aborted* What could be the possible reasons for this and how do I rectify it? ...

How to identify which function call threw a particular exception in a try block?

Let's say there are three consecutive function calls in one try block and all of them throw the same type of exception. How can i figure out which function call threw the caught exception when handling it? ...