Fix device returned error handling