From 4920152e28f1aa2d151bd0157ab05f5abdff0c94 Mon Sep 17 00:00:00 2001 From: LangLangbart <92653266+LangLangBart@users.noreply.github.com> Date: Thu, 11 Jan 2024 10:49:09 +0100 Subject: [PATCH] fix: improve error message for failed search results --- gh-find-code | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gh-find-code b/gh-find-code index 0f95dd5..80c795e 100755 --- a/gh-find-code +++ b/gh-find-code @@ -287,6 +287,7 @@ gh_query() { done : >"$store_pids" fi + curl_custom "transform-header:printf '%bSearching…%b' '$DARK_GRAY' '$COLOR_RESET'" if ! data=$(command gh api search/code \ --method GET \ --cache "$gh_default_cache_time" \ @@ -306,12 +307,12 @@ gh_query() { # extended grep patterns: ([.value.text_matches[] | .. | .text? | select(type=="string")] as $patterns_array | if $patterns_array == [] then "__NoPatternFound__" else $patterns_array | unique | join("|") end) - } | [.index, .owner_repo_name, .file_name, .file_path, .patterns] | @tsv)' 2>"$store_gh_search_debug"); then - curl_custom "transform-header:printf '%bFailed to get the search results, check the query syntax.%b' \ + } | [.index, .owner_repo_name, .file_name, .file_path, .patterns] | @tsv)' \ + 2>"$store_gh_search_debug") || [[ -z $data ]]; then + curl_custom "transform-header:printf '%bFailed to get the search results!\n\t- Check query syntax\n\t- Check internet connection%b' \ '$RED_NORMAL' '$COLOR_RESET'" return else - curl_custom "transform-header:printf '%bSearching…%b' '$DARK_GRAY' '$COLOR_RESET'" ({ # first line IFS=' ' read -r items total_count