Use the command echo $? to check the exit status of the most recently executed command. If it returns the value 0, it means the compilation failed.