File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,6 +80,17 @@ exp_retry() {
8080 sleep " $wait_sec "
8181}
8282
83+ # shorten a string in the middle, if it is too large
84+ shorten_string () {
85+ local sstring=" $1 "
86+ local max_str_len=${max_str_len:- " 120" }
87+ local max_str_len_half=$(( max_str_len / 2 ))
88+ if [[ ${# sstring} -gt $max_str_len ]]; then
89+ sstring=${sstring: 0: $max_str_len_half } …${sstring: -$max_str_len_half }
90+ fi
91+ echo " $sstring "
92+ }
93+
8394# Wrapper around curl that reports the HTTP status if it is not 200, and the
8495# calling command and line
8596# exp_retries: number of total tries - 0/unset for no retries. Sleep before each retry will double.
@@ -94,6 +105,7 @@ runcurl() {
94105 rc=$?
95106 set -e
96107 if [[ " $rc " != 0 ]]; then
108+ response=$( shorten_string " $response " )
97109 warn " curl ($( caller) ): Error fetching ($* ): $response "
98110 # shellcheck disable=SC2015
99111 exp_retry " $exp_retries " " $retry_exponent " && continue || break
You can’t perform that action at this time.
0 commit comments