If you want to test the success or failure of a command, you can rely on its exit code. Knowing that each command will return a 0 on success or any other number on failure, you have a few options on how to handle each command's errors.
|| handler
npm run build:prod || exit 1
if condition
if docker-compose -f .docker/docker-compose.ecr.yml build my-app; then
  printf "success\n"
else
  printf "failure\n"
  exit 1
fi
the $? variable
docker-compose -f .docker/docker-compose.ecr.yml push my-app
if [ $? -gt 0 ]; then
  printf "Failure\n"
  exit 1
fi
traps
err_report() {
    echo "Error on line $1"
}
trap 'err_report $LINENO' ERR
aws ecs update-service --cluster ...
set -e
To globally "exit on error", then set -e will do just that. It won't give you much info, but it'll get the job done.