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 ...
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 ...
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.
...
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...
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...
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 ...
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...
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...
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...
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?
...
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...
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,
...
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?
...
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 :
...
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...
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...
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...
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
{
...
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?
...
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?
...