From 5a9c3ad353c57e098c1a683b673f840ecd31081b Mon Sep 17 00:00:00 2001
From: Humberto Evans <hevans66@gmail.com>
Date: Tue, 13 Feb 2024 17:27:59 -0800
Subject: [PATCH] move try/catch into main control flow and more from code
 review comments

---
 server/notification-providers/heii-oncall.js | 41 ++++++++++----------
 src/components/notifications/HeiiOnCall.vue  | 10 ++---
 src/lang/en.json                             |  4 +-
 3 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/server/notification-providers/heii-oncall.js b/server/notification-providers/heii-oncall.js
index 75ebf6140..585fa1381 100644
--- a/server/notification-providers/heii-oncall.js
+++ b/server/notification-providers/heii-oncall.js
@@ -17,19 +17,24 @@ class HeiiOnCall extends NotificationProvider {
             payload["url"] = baseURL + getMonitorRelativeURL(monitorJSON.id);
         }
 
-        if (!heartbeatJSON) {
-            // Testing or general notification like certificate expiry
-            payload["msg"] = msg;
-            return this.postNotification(notification, "alert", payload);
+        try {
+            if (!heartbeatJSON) {
+                // Testing or general notification like certificate expiry
+                payload["msg"] = msg;
+                return this.postNotification(notification, "alert", payload);
+            }
+
+            if (heartbeatJSON.status === DOWN) {
+                return this.postNotification(notification, "alert", payload);
+            }
+
+            if (heartbeatJSON.status === UP) {
+                return this.postNotification(notification, "resolve", payload);
+            }
+        } catch (error) {
+            this.throwGeneralAxiosError(error);
         }
 
-        if (heartbeatJSON.status === DOWN) {
-            return this.postNotification(notification, "alert", payload);
-        }
-
-        if (heartbeatJSON.status === UP) {
-            return this.postNotification(notification, "resolve", payload);
-        }
     }
 
     /**
@@ -49,15 +54,11 @@ class HeiiOnCall extends NotificationProvider {
         };
 
         // Post to Heii On-Call Trigger https://heiioncall.com/docs#manual-triggers
-        try {
-            await axios.post(
-                `https://heiioncall.com/triggers/${notification.heiiOnCallTriggerId}/${action}`,
-                payload,
-                config
-            );
-        } catch (error) {
-            this.throwGeneralAxiosError(error);
-        }
+        await axios.post(
+            `https://heiioncall.com/triggers/${notification.heiiOnCallTriggerId}/${action}`,
+            payload,
+            config
+        );
 
         return "Sent Successfully";
     }
diff --git a/src/components/notifications/HeiiOnCall.vue b/src/components/notifications/HeiiOnCall.vue
index 54c991344..7ae516c73 100644
--- a/src/components/notifications/HeiiOnCall.vue
+++ b/src/components/notifications/HeiiOnCall.vue
@@ -9,7 +9,7 @@
         ></HiddenInput>
     </div>
     <div class="mb-3">
-        <label for="heiioncall-trigger-id" class="form-label">{{ $t("Trigger ID") }}<span
+        <label for="heiioncall-trigger-id" class="form-label">Trigger ID<span
             style="color: red;"
         ><sup>*</sup></span></label>
         <HiddenInput
@@ -17,11 +17,9 @@
             autocomplete="false"
         ></HiddenInput>
     </div>
-    <div class="form-text">
-        <i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" style="margin-top: 8px;">
-            <a href="https://heiioncall.com/docs" target="_blank">{{ $t("documentationOf", ["Heii On-Call"]) }}</a>
-        </i18n-t>
-    </div>
+    <i18n-t tag="p" keypath="wayToGetHeiiOnCallDetails" class="form-text mt-3">
+        <a href="https://heiioncall.com/docs" target="_blank">{{ $t("documentationOf", ["Heii On-Call"]) }}</a>
+    </i18n-t>
 </template>
 
 <script>
diff --git a/src/lang/en.json b/src/lang/en.json
index e95dc56c2..c0fd304af 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -884,6 +884,6 @@
     "GrafanaOncallUrl": "Grafana Oncall URL",
     "Browser Screenshot": "Browser Screenshot",
     "What is a Remote Browser?": "What is a Remote Browser?",
-    "Trigger ID": "Trigger ID",
-    "wayToGetHeiiOnCallDetails": "How to get the Tigger ID and API Keys is explained in the {documentation}"
+    "wayToGetHeiiOnCallDetails": "How to get the Tigger ID and API Keys is explained in the {0}",
+    "documentationOf": "{0} Documentation"
 }