Top "Exception" questions

An exception is an unusual condition that requires deviation from the program's normal flow.

How can I safely create a nested directory?

What is the most elegant way to check if the directory a file is going to be written to exists, …

python exception path directory operating-system
Manually raising (throwing) an exception in Python

How can I raise an exception in Python so that it can later be caught via an except block?

python exception
How do you assert that a certain exception is thrown in JUnit 4 tests?

How can I use JUnit4 idiomatically to test that some code throws an exception? While I can certainly do something …

java exception junit junit4 assert
How to solve java.lang.NoClassDefFoundError?

I've tried both the example in Oracle's Java Tutorials. They both compile fine, but at run-time, both come up with …

java exception packages noclassdeffounderror
How do I check if a variable exists?

I want to check if a variable exists. Now I'm doing something like this: try: myVar except NameError: # Do something. …

python exception variables
How to properly ignore exceptions

When you just want to do a try-except without handling the exception, how do you do it in Python? Is …

python exception try-except
Dealing with "java.lang.OutOfMemoryError: PermGen space" error

Recently I ran into this error in my web application: java.lang.OutOfMemoryError: PermGen space It's a typical Hibernate/JPA + …

exception memory-leaks out-of-memory java-6 permgen
What could cause java.lang.reflect.InvocationTargetException?

Well, I've tried to understand and read what could cause it but I just can't get it: I have this …

java exception reflection invoke
How to print an exception in Python?

try: something here except: print('the whatever error occurred.') How can I print the error/exception in my except: …

python exception error-handling
Catch multiple exceptions in one line (except block)

I know that I can do: try: # do something that may fail except: # do this if ANYTHING goes wrong I …

python exception exception-handling