Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Multiple Datasource] Add API Call Error Handling: Simulate Network Error and 404 Response #6738

Closed
Tracked by #6600
yujin-emma opened this issue May 7, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request multiple datasource multiple datasource project v2.15.0

Comments

@yujin-emma
Copy link
Contributor

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.

@yujin-emma yujin-emma added the enhancement New feature or request label May 7, 2024
@yujin-emma yujin-emma self-assigned this May 7, 2024
@BionIT
Copy link
Collaborator

BionIT commented Jun 3, 2024

Hi @yujin-emma, are we targeting to address this in 2.15 or 2.16?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request multiple datasource multiple datasource project v2.15.0
Projects
None yet
Development

No branches or pull requests

3 participants