MDL-33799-check-return-value add if and do the error handling