Check return code when calling subprocess and throw better error

closes #2898