If you're using grep with set -euo pipefail and don't want to exit if no record is found (exit code = 1), but still want it to fail if it's another exit code, you can use this:
#!/bin/bash
set -euo pipefail
echo "anything" | { grep e || test $? = 1; } | { grep e2 || test $? = 1; }
The greps inside the pipes will ONLY ignore exit status = 1. This way you don't need to lose the benefits of using set -euo pipefail.
In this example I purposely included two piped greps that could fail to illustrate the concept.
Very well explained onRefer to myrdd's post there.