Dispatch exceptions

This allows applications to hook in and add their own logic as appropriate (e.g. logging, reporting) when exceptions are passed up.

Sorry about the additional commits in here; it seems that the other branches are not fully merged in...  Possibly I'm just not using git correctly here.