Skip to content

Commit

Permalink
add try catch
Browse files Browse the repository at this point in the history
Signed-off-by: Qxisylolo <[email protected]>
  • Loading branch information
Qxisylolo committed Jan 6, 2025
1 parent 7764cfd commit 58c3407
Showing 1 changed file with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,11 @@ const convertConnectionsToOptions = ({

if (connection.connectionType === DataSourceConnectionType.OpenSearchConnection) {
if (showDirectQueryConnections) {
if (!connection.relatedConnections || connection.relatedConnections.length === 0) {
// return [connection] for the case where the connnection has no direct connections for now, but it may have in the future
return [connection];
}
return [
connection,
...(selectedConnectionIds.includes(connection.id) ? connection.relatedConnections : []),
...(selectedConnectionIds.includes(connection.id)
? connection.relatedConnections ?? []
: []),
];
}
}
Expand Down Expand Up @@ -292,13 +290,22 @@ export const AssociationDataSourceModalContent = ({

const fetchDataSourcesAndHandleRelatedConnections = async () => {
setIsLoading(true);
const { openSearchConnections, dataConnections } = await fetchDataSources();
const connections = await handleDirectQueryConnections(
openSearchConnections,
dataConnections
);
setAllConnections(connections);
setIsLoading(false);
try {
const { openSearchConnections, dataConnections } = await fetchDataSources();
const connections = await handleDirectQueryConnections(
openSearchConnections,
dataConnections
);
setAllConnections(connections);
} catch {
notifications?.toasts.addDanger(

Check warning on line 301 in src/plugins/workspace/public/components/data_source_association/association_data_source_modal.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/workspace/public/components/data_source_association/association_data_source_modal.tsx#L301

Added line #L301 was not covered by tests
i18n.translate('workspace.detail.dataSources.associateModal.fetchDataSourcesError', {
defaultMessage: 'Failed to get data sources',
})
);
} finally {
setIsLoading(false);
}
};

fetchDataSourcesAndHandleRelatedConnections();
Expand Down

0 comments on commit 58c3407

Please sign in to comment.