From a69d65f481a1e02a376324f7d6e6227a56bc81d2 Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Thu, 4 Jan 2024 13:06:15 +0000 Subject: [PATCH] Tidy up error handling --- dnsapi/dns_gcloud.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/dnsapi/dns_gcloud.sh b/dnsapi/dns_gcloud.sh index f80decc2..d83b108e 100755 --- a/dnsapi/dns_gcloud.sh +++ b/dnsapi/dns_gcloud.sh @@ -58,19 +58,27 @@ _dns_gcloud_start_tr() { gcloud dns record-sets transaction start \ --transaction-file="$tr" \ --zone="$managedZone" - rc=$? + + rc=$? + if $rc != 0; then _err "_dns_gcloud_start_tr: RC= $rc failed to execute transaction" - return 0 + fi + + return $rc } _dns_gcloud_execute_tr() { gcloud dns record-sets transaction execute \ --transaction-file="$tr" \ --zone="$managedZone" - rc=$? + rc=$? + + if $rc != 0; then _debug tr "$(cat "$tr")" _err "_dns_gcloud_execute_tr: RC= $rc failed to execute transaction" + return $rc + fi for i in $(seq 1 120); do if gcloud dns record-sets changes list \ @@ -107,10 +115,14 @@ _dns_gcloud_add_rrs() { --type=TXT \ --zone="$managedZone" \ --transaction-file="$tr" - rc=$? + + rc=$? + if $rc != 0; then _debug tr "$(cat "$tr")" _err "_dns_gcloud_add_rrs: rc=$rc failed to add RRs" - return 0 + fi + + return $rc } _dns_gcloud_find_zone() {