[SPARK-3877][YARN] Throw an exception when application is not successful so that the exit code wil be set to 1 (for branch-1.1)

This is a patch to fix SPARK-3877 in branch-1.1. See also #2732