Skip to content

Commit ad00cfe

Browse files
committed
Fix error handling for Help Forum integration
1 parent f07c946 commit ad00cfe

2 files changed

Lines changed: 37 additions & 10 deletions

File tree

client/src/components/Tool/ToolHelpForum.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import { computed, onMounted, ref } from "vue";
66
import { GalaxyApi } from "@/api";
77
import { galaxyLogo } from "@/components/icons/galaxyIcons";
88
import { useConfigStore } from "@/stores/configurationStore";
9+
import { errorMessageAsString } from "@/utils/simple-error";
910
import { getShortToolId } from "@/utils/tool";
1011
1112
import { createTopicUrl, type HelpForumPost, type HelpForumTopic, useHelpURLs } from "./helpForumUrls";
1213
14+
import Alert from "@/components/Alert.vue";
1315
import Heading from "@/components/Common/Heading.vue";
1416
import ExternalLink from "@/components/ExternalLink.vue";
1517
@@ -22,6 +24,7 @@ const toolHelpTag = "tool-help";
2224
2325
const topics = ref<HelpForumTopic[]>([]);
2426
const posts = ref<HelpForumPost[]>([]);
27+
const errorMessage = ref("");
2528
const helpAvailable = computed(() => topics.value.length > 0);
2629
2730
const root = ref(null);
@@ -36,7 +39,7 @@ onMounted(async () => {
3639
},
3740
});
3841
if (error) {
39-
console.error("Error fetching help forum data", error);
42+
errorMessage.value = errorMessageAsString(error, "Failed to search the Help Forum.");
4043
}
4144
4245
topics.value = data?.topics ?? [];
@@ -66,12 +69,14 @@ const configStore = useConfigStore();
6669
<div ref="root" class="tool-help-forum mt-2 mb-4">
6770
<Heading h2 separator bold size="sm">Help Forum</Heading>
6871

72+
<Alert v-if="errorMessage" variant="warning" :message="errorMessage" />
73+
6974
<p v-if="helpAvailable">
7075
Following questions on the
7176
<ExternalLink :href="configStore.config.help_forum_api_url"> Help Forum </ExternalLink> may be related to
7277
this tool:
7378
</p>
74-
<p v-else>
79+
<p v-else-if="!errorMessage">
7580
There are no questions on the
7681
<ExternalLink :href="configStore.config.help_forum_api_url"> Help Forum </ExternalLink>
7782
about this tool.

lib/galaxy/webapps/galaxy/services/help.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import logging
22

33
from galaxy.config import GalaxyAppConfiguration
4-
from galaxy.exceptions import ServerNotConfiguredForRequest
4+
from galaxy.exceptions import (
5+
InternalServerError,
6+
MessageException,
7+
ServerNotConfiguredForRequest,
8+
)
59
from galaxy.schema.help import HelpForumSearchResponse
610
from galaxy.security.idencoding import IdEncodingHelper
711
from galaxy.util import requests
@@ -34,10 +38,28 @@ def search_forum(self, query: str) -> HelpForumSearchResponse:
3438
if not self.config.help_forum_api_url:
3539
raise ServerNotConfiguredForRequest("Help forum API URL is not configured.")
3640
forum_search_url = f"{self.config.help_forum_api_url}/search.json"
37-
response = requests.get(
38-
url=forum_search_url,
39-
params={
40-
"q": query,
41-
},
42-
)
43-
return HelpForumSearchResponse(**response.json())
41+
try:
42+
response = requests.get(
43+
url=forum_search_url,
44+
params={
45+
"q": query,
46+
},
47+
)
48+
except requests.exceptions.ConnectionError:
49+
raise MessageException(
50+
"Could not connect to the Galaxy Help Forum. The service may be temporarily unavailable."
51+
)
52+
except requests.exceptions.Timeout:
53+
raise MessageException("The request to the Galaxy Help Forum timed out. Please try again later.")
54+
except requests.exceptions.RequestException as e:
55+
raise InternalServerError(f"An error occurred while requesting the Galaxy Help Forum: {e}")
56+
57+
if not response.ok:
58+
raise MessageException(
59+
f"The Galaxy Help Forum returned an error (HTTP {response.status_code}). Please try again later."
60+
)
61+
62+
try:
63+
return HelpForumSearchResponse(**response.json())
64+
except ValueError as e:
65+
raise InternalServerError(f"Received an unexpected response format from the Galaxy Help Forum: {e}")

0 commit comments

Comments
 (0)