exception

hasattr() vs try-except block to deal with non-existent attributes

if hasattr(obj, 'attribute'): # do somthing vs try: # access obj.attribute except AttributeError, e: # deal with AttributeError Which should be preferred and why? ...

COM Exceptions in C#

I am consuming a cpp COM object from c# code. My c# code looks like this: try { var res = myComServer.GetSomething(); } catch (Exception e) { } However the exception never contains any of the details I set in cpp, in particular my error message. In my cpp side I have followed several examples I have found on the web: ... ICreateE...

Java Exceptions Loops and Deprecation (or is it a URLEncoding thing?)

I just wrote a whole blurb on how I reached this point, but figured it's easier to post the code and leave it at that :) As far as I can tell, the performance of test3() should be the same as test1() - the only difference is where the exception is caught (inside the calling method for test1(), inside the called method for test3()) Why ...

Java Security Exception

Hello! I am trying to integrate a Hibernate application into a proprietary framework. My problem is that this framework somehow checks the signature of packages. When I try to call my Hibernate application I get the following error: Caused by: java.lang.SecurityException: class "org.hibernate.dialect.Oracle10gDialect"'s signer infor...

"The format of the URI could not be determined" with WebRequest

I'm trying to perform a POST to a site using a WebRequest in C#. The site I'm posting to is an SMS site, and the messagetext is part of the URL. To avoid spaces in the URL I'm calling HttpUtility.Encode() to URL encode it. But I keep getting an URIFormatException - "Invalid URI: The format of the URI could not be determined" - when I us...

Can someone explain "ClassCastException" in Java?

I read some articles written on "ClassCastException" but I couldn't get a good idea on that. Can someone direct me to a good article or explain it briefly. ...

In C++, is is possible to throw an exception that will not be caught by std::exception?

Question 1: Is is possible to throw an exception that will not be caught by std::exception? try { } catch(std::exception & e) { } catch(...) { //Is this block needed? } Question 2: Is it better to have: catch(std::exception & e) Or catch(std::exception e) Or catch(const std::exception &e)//<--- this is the method I usuall...

Why do I get "Exception; must be caught or declared to be thrown" when I try to compile my Java code?

import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.crypto.*; import javax.crypto.spec.*; import java.security.*; import java.io.*; public class EncryptURL extends JApplet implements ActionListener { Container content; JTextField userName = new JTextField(); JTextField firstName = new JTextField(); ...

Catch 404 exception from StaticFileModule in IIS7 integrated pipeline mode

Hi ! Does anyone know if there is a good programatic way (not using the CustomError settings) to catch / handle an 404 error coming from the StaticFileModule in integrated pipeline mode on a IIS7 ? /b ...

Differences betweeen Exception and Error

I'm trying to learn more about basic Java and the different types of Throwables, can someone let me know the differences between Exceptions and Errors? ...

Throw Exceptions with custom stack trace.

Is it possible to throw an exception (could be any exception) with a customized stack trace? As a concrete example: lets say I have a set of some small static utility methods which might throw exceptions. However I would like the exception to appear to have originated from the previous method instead of the utility method (I want to ign...

What are the pros and cons of checked exception?

Do you prefer checked exception handling like in Java or unchecked exception handling like in C# and why? ...

Can't catch exception!

I'm using swig to wrap a class from a C++ library with python. It works overall, but there is an exception that is thrown from within the library and I can't seem to catch it in the swig interface, so it just crashes the python application! The class PyMonitor.cc describes the swig interface to the desired class, Monitor. Monitor's cons...

Why is UnhandledExceptionEventArgs.ExceptionObject an object and not an Exception?

Why is UnhandledExceptionEventArgs.ExceptionObject an object and not an Exception? I am attaching to AppDomain.UnhandledException. I would like to cast UnhandledExceptionEventArgs.ExceptionObject to an Exeption and interogate it. And with this in mind will it ever be null? The MSDN documentation is not exatly useful http://msdn.mic...

What is causing this MySQLSyntaxError exception?

Hi all, i written this query (in java class) to select some information from the MySQL database and view it on jsp page... SELECT instructor.name FROM instructor,section,teach WHERE teach.student_id='3'AND teach.section = section.number AND section.instructor_id= instructor.ID but there is exception was occur! javax.serv...

BufferOverflowException when generating Javadoc?

Hi, Has anybody ever had problems with the javadoc tool causing a java.nio.BufferOverflowException? I'm trying to generate Javadoc for code with Japanese comments (charset MS932). I think that might be related. Does anybody know of a workaround for this problem? Here's the stacktrace: java.nio.BufferOverflowException at java.nio.Buff...

Is it possible for a library consumer to override C++ exceptions handling?

I have a C++ DLL with code like this: LogMessage( "Hello world" ); try { throw new int; } catch( int* e ) { LogMessage( "Caught exception" ); delete e; } LogMessage( "Done" ); This DLL is loaded by some third-party application and the code above is invoked. The problem is only the first LogMessage is invoked - even though ...

Convert.ToInt32 versus TryParse

We all know the effects that lots of thrown exceptions can have over the performance of our applications, thus, we should stay away from things like using exceptions for control flow. After this statement I must confess that when coding I didn't care that much about this. I've been working mostly on Java platform but lately I was doing i...

How do I chose the most appropriate type of exception to throw?

There are already lots of questions on SO about exceptions, but I can't find one that answers my question. Feel free to point me in the direction of another question if I've missed it. My question is quite simple: how do other (C#) developers go about choosing the most appropriate type of exception to throw? Earlier I wrote the follow...

Way to automatically see which functions can potentially return exception in c#

Hi, nothing more frustrating than to see your code crash in the debugger on a method which exceptionned and you didn't try/catch it. Is there an easy way to scan through your sources and tag all functions which can potentially throw exceptions? Does the build in visual assist have some hidden option to colour these functions in a spec...