Give curl several URLs and, by default, only the last one decides the exit code. A failed first download followed by a good second one returns 0, and your script carries on.
Add --fail-early and curl stops at the first failure and returns its error:
curl -fsS --fail-early \
-O https://example.com/release/app.tar.gz \
-O https://example.com/release/app.tar.gz.sha256
echo $?
If the first file returns a 404, curl prints the error, skips the second file and exits with 22. Without the option it would fetch the checksum file and exit with 0, and a step later you would be checking a file that does not exist.
The -f matters here. --fail-early reacts to transfer errors, and a 404 only counts as one when -f is set. The man page says the same: the option does not imply --fail.
I’d add it to any command or config file that downloads more than one thing a later step depends on. The flag is global, so it applies to every URL in the command, including ones after --next. It does not undo transfers that already finished, so files from earlier URLs stay on disk.
Further reading: curl man page