Adds a fail callback

Added support for a fail callback - per #219. I closed the previous request because I had selected the wrong branch