(( ${#array[@]} )) || { echo "array is empty"; exit 1; }
where (( ${#array[@]} )) checks the array length.
(( ${#array[@]} ))