exception

exception not getting caught when not in the right package in python

EDIT: OK, I managed to isolate the bug and the exact, complete code to to reproduce it. But it appears either something that's by design, or a bug in python. Create two sibling packages: admin & General, each with it's own __init__.py, of course. In the package admin put the file 'test.py' with the following code: from General.test02 i...

The throws keyword for exceptions in Java

when you do this: public class Blah { public void doBlah() throws BlahException { } } What does adding the throws BlahException really do? Does it basically group any exception to that one? i.e. if there is an exception, no matter what it is, will always be thrown using BlahException? ...

J2ME Application problem! (Null pointer exception)

Hello there, I'm creating an application that installs 3 Record Stores for the first run. Then on it has to work with the already installed values. The application works fine during the first run both in the emulator and in a mobile. But the second time run shows a null pointer exception after my splash screen loads. After the splash scr...

Catching expected exceptions

I've got code that looks like this because the only reliable way for me to check if some data is an image is to actually try and load it like an image. static void DownloadCompleted(HttpConnection conn) { Image img; HtmlDocument doc; try { img = Image.FromStream(conn.Stream); } catch { ...

python: Should I use ValueError or create my own subclass to handle invalid strings?

I've looked through python's built in exceptions and the only thing that seems close is ValueError. from python documentation: exception ValueError: Raised when a built-in operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception su...

compilation error about exceptions

Hi, I met some compilation error but do not know what the problem is. The code seems not use exception, but the error is about it. //in misc.h: char *basename(char *name); // line 94 // in misc.cc: char *basename(char *name) { // line 12 char *result = name; while(*name) { if(*name == '/') result = name + 1; name++;...

Magic Exception thrower without declaring throws Exception.

I want a method that can throw any Throwable including sub classes of Exception. Ive got something that takes an exception, stashes it in a thread local, then invokes a class.newInstance. That class ctor declares that it throws Exception then takes the threadlocal and throws it. Problem is it does not work for the two declared Exceptions...

How do division-by-zero exceptions work?

How is division calculated on compiler/chip level? And why does C++ always throw these exceptions at run-time instead of compile-time (in case the divisor is known to be zero at compile time)? ...

How are exceptions implemented under the hood?

Just about everyone uses them, but many, including me simply take it for granted that they just work. I am looking for high-quality material. Languages I use are: Java, C, C#, Python, C++, so these are of most interest to me. Now, C++ is probably a good place to start since you can throw anything in that language. Also, C is close to...

Unhandled exception in try-catch

try { list = from XElement e in d.Descendants(wix + "File") where e.Attribute("Name").Value.Contains(temp.Name) && e.Parent.Parent.Attribute("Name").Value.Contains(temp.Directory.Name) select e; } catch (NullReferenceException e) { MessageBox.Show(e.Message); } catch (Exception e) { Mess...

Is there a standard "never returns" attribute for C# functions ?

I have one method that looks like this: void throwException(string msg) { throw new MyException(msg); } Now if I write int foo(int x, y) { if (y == 0) throwException("Doh!"); else return x/y; } the compiler will complain about foo that "not all paths return a value". Is there an attribute I can add to t...

Logging Exceptions Location within a DAL Class

I am not sure where the best location to handle my exceptions in my DAL class. I have some code that does a read, and populates a list of business objects like the pseudo-code below: public List<MyObject> GetMyObjects() { while (dataReader.Read() { try { //populate business object } cat...

Error Log Database -- For many apps

I have a bunch of existing client/server applications that are currently chugging along. Once in a while, a client will want to add on some type of web-interface to access part of their data. These are typically custom, although some are "generic"; but everyone has their own "instance" in its own VM. What I want is a centralized area to...

Better way to access break-on-exception filter when debugging in Visual Studio?

I'm tired of using the eye-squinting, time-consuming Exceptions dialog in Visual Studio to turn break-on-exception filters on and off. I looked for a Visual Studio command to help automate this from the Command window, but no luck. Does anyone have a technique for avoiding the Debug->Exceptions dialog yet get access to its functionality...

Error in starting namenode in Hadoop

hi, When I try to format the namenode or even start it I'm getting the below error. What should be done?? $ bin/hadoop namenode -format Exception in thread "main" java.lang.NoClassDefFoundError: Caused by: java.lang.ClassNotFoundException: at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.securi...

Different exception handling in XP and Vista

Hi I have a weird issue. Say you have the following: Application.ThreadException += something; try { Application.Run(new Form1()); } catch (Exception ex) { } Now given an exception happens somewhere in the app, Vista raises the ThreadException event, but XP just jumps straight to the catch block. How do I get the handling to beh...

C++ exception handling with source code line info

Is there a way catch an exception like access violation and get information about on which line an exception occurred? This would be very good for debugging purposes, especially for testers.. My environment is Windows with VC++ on VS2008 ...

UnexpectedRollbackException - a full scenario analysis

All I know about this exception is from Spring's documentation and some forum posts with frostrated developers pasting huge stack traces, and no replies. From Spring's documentation: Thrown when an attempt to commit a transaction resulted in an unexpected rollback I want to understand once and for all Exactly what causes it? ...

Some help tracking down an exception while loading a form with a SMDBGrid

I've got a form with a DB grid on it. It worked fine as a normal TDBGrid, but when I replaced it with the Scalabium TSMDBGrid, I started getting exceptions while loading the form. Here's the problem, as far as I can track it down: While loading the columns from the DFM, it attempts to set the Expanded property on the first column to F...

Why do you have to write throws exception in a class definition?

Coming from C#, I just don't get this 'throws exception' that is written after a class/method definition: public void Test() throws Exception Do you have to write this? What if you don't? If I call a method that has this symbol, do I have to catch it? ...