No Such Element Exception?

It looks like you are calling next even if the scanner no longer has a next element to provide… throwing the exception. while(!file.next().equals(treasure)){ file.next(); } Should be something like boolean foundTreasure = false; while(file.hasNext()){ if(file.next().equals(treasure)){ foundTreasure = true; break; // found treasure, if you need to use it, assign to variable beforehand } } // … Read more

What is causing my OLEDbException, IErrorInfo.GetDescription failed with E_FAIL(0x80004005)

I apparently was mistaken when I said the query did not contain any reserved words. The query I was using was selecting from another query in the Access Database. That other query had a reserved keyword that was causing the problem. BTW: The Access database engine runs in different modes, depending on whether it is … Read more

In Java, what is the difference between catch a generic exception and a specific exception (eg. IOException?)

The difference between performing a general try/catch statement and catching a specific exception (e.g. a FileNotFoundException) typically depend on what errors you need to handle and what errors you don’t need to worry about. For instance: catch (Exception e) { //A (too) general exception handler … } The code above will catch EVERY exception that … Read more

Android: ClassNotFoundException when passing serializable object to Activity

Finally reached a conclusion on this issue: it was being caused by Proguard, or more specifically, because I didn’t have a propper Proguard configuration. It turns out Proguard was changing my Serializable‘s classes names, which makes Class.forName(className) fail. I had to reconfigure my proguard.cfg file adding the following lines: -keep class * implements java.io.Serializable -keepclassmembers … Read more

GWT.setUncaughtExceptionHandler()

I believe what’s happening here is that the current JS event cycle is using the DefaultUncaughtExceptionHandler because that was the handler set at the start of the cycle. You’ll need to defer further initialization to the next event cycle, like this: public void onModuleLoad() { GWT.setUncaughtExceptionHandler(new ClientExceptionHandler()); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { … Read more

Which types of exception not to catch?

The usual advice applies, only catch what you can handle. There’s a utility function named IsCriticalException inside the framework that’s pretty commonly used by parts of the framework code to decide whether or not to swallow an exception. Might as well go by that. It considers the following critical: NullReferenceException StackOverflowException (uncatchable) OutOfMemoryException ThreadAbortException ExecutionEngineException … Read more