OpenSearch-Dashboards
OpenSearch-Dashboards copied to clipboard
[Multiple Datasource] Add API Call Error Handling: Simulate Network Error and 404 Response
Is your feature request related to a problem? Please describe.
export async function getDataSourceById(
id: string,
savedObjectsClient: SavedObjectsClientContract
) {
const response = await savedObjectsClient.get('data-source', id);
if (!response || response.error) {
throw new Error('Unable to find data source');
}
const attributes: any = response?.attributes || {};
return {
id: response.id,
title: attributes.title,
endpoint: attributes.endpoint,
description: attributes.description || '',
auth: attributes.auth,
};
}
This function only return generic error, and the usage of this function not handle the network error, we need to add the handling for this part
Describe the solution you'd like
Use OsdError
instead of Error
Add test for non-OsdError to mock network issue
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/data_source_management/public/components/utils.ts#L153
Hi @yujin-emma, are we targeting to address this in 2.15 or 2.16?