Skip to content

Commit

Permalink
fix(frontend): more graceful handling for TMAlphaFold (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
t03i authored Nov 20, 2024
1 parent 7328764 commit 50ff091
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions frontend/src/lib/external/tmAlphaFold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0

import { createQuery } from '@tanstack/svelte-query';
import { type Readable } from 'svelte/store';
import axios from 'axios';
import type { PublicAnnotation, AnnotationData } from '$lib/client/model';

Expand Down Expand Up @@ -37,9 +36,18 @@ const tmalphafold_parse_response = (body: any, up_name: string): AnnotationData

export const getTMAlphaFoldAnnotation = async (up_name: string, signal: AbortSignal) => {
const url = tmalphafold_query_url(up_name);
const { data } = await axios.get(url);
return tmalphafold_parse_response(data, up_name);
};
try {
const { data } = await axios.get(url);
return tmalphafold_parse_response(data, up_name);
} catch (error) {
if (axios.isAxiosError(error) && error.response?.status === 500) {
// Return empty annotation data when the server indicates no data is available
return { annotations: [] };
}
// Re-throw other errors
throw error;
}
};


// TODO better solution for queryClient
Expand Down

0 comments on commit 50ff091

Please sign in to comment.