Added support for overriding failure handler in js