added an optional callback before handling an exception