Allow for custom failure function