Fix sample error handling