Add more information to some exceptions.

If an exception has an unknown target, that's always a bug. However, those types of bugs tend to be hard to track down, so this commit adds more information to the exception report if debug mode is on.