Skip to content

Commit 32f860f

Browse files
Log an error in case the eth price fetch fails
1 parent 433298c commit 32f860f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

alerts/sender_with_alert.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,12 @@ done
181181
wei_to_eth_division_factor=$((10**18))
182182
spent_amount=$(echo "scale=30; $total_fee_in_wei / (10^18)" | bc -l | awk '{printf "%.15f", $0}')
183183

184-
eth_usd=$(curl -s https://cryptoprices.cc/ETH/)
184+
eth_usd=$(curl -s --connect-timeout 10 --max-time 30 https://cryptoprices.cc/ETH/ 2>/dev/null)
185+
if [[ -z "$eth_usd" ]] || ! [[ "$eth_usd" =~ ^[0-9]+\.?[0-9]*$ ]]; then
186+
echo "Warning: Could not fetch ETH price, using fallback value of 4000"
187+
eth_usd=4000
188+
fi
189+
185190
spent_amount_usd=$(echo "$spent_amount * $eth_usd" | bc | awk '{printf "%.2f", $1}')
186191

187192
verified=1

0 commit comments

Comments
 (0)