diff --git a/apps/deepsirius-ui/src/components/hello.tsx b/apps/deepsirius-ui/src/components/hello.tsx
index 5074b21..ac7128b 100644
--- a/apps/deepsirius-ui/src/components/hello.tsx
+++ b/apps/deepsirius-ui/src/components/hello.tsx
@@ -1,11 +1,19 @@
import { api } from '~/utils/api';
export default function Hello() {
- const { data, isLoading } = api.tbConsumer.hello.useQuery();
+ const { data, isLoading, isError, error } = api.tbConsumer.hello.useQuery();
if (isLoading) {
return
Loading...
;
}
+ if (isError) {
+ return (
+
+
Error: {error?.message}
+
{JSON.stringify(error?.data, null, 2)}
+
+ );
+ }
return (
diff --git a/apps/deepsirius-ui/src/server/api/routers/tb_consumer.ts b/apps/deepsirius-ui/src/server/api/routers/tb_consumer.ts
index a6dc80d..3f6cfc4 100644
--- a/apps/deepsirius-ui/src/server/api/routers/tb_consumer.ts
+++ b/apps/deepsirius-ui/src/server/api/routers/tb_consumer.ts
@@ -50,14 +50,28 @@ export const tbConsumerRouter = createTRPCRouter({
}),
hello: protectedProcedure.query(async () => {
const url = `${env.TENSORBOARD_API_URL}/api/`;
- const res = await fetch(url, {
- method: 'GET',
- headers: {
- 'x-api-key': env.TENSORBOARD_API_KEY,
- },
- });
+ try {
+ const res = await fetch(url, {
+ method: 'GET',
+ headers: {
+ 'x-api-key': env.TENSORBOARD_API_KEY,
+ },
+ });
- const data: unknown = await res.json();
- return data;
+ const data: unknown = await res.json();
+ return data;
+ } catch (e) {
+ const error = z
+ .object({
+ status: z.string(),
+ message: z.string(),
+ })
+ .parse(e);
+ throw new TRPCError({
+ code: 'INTERNAL_SERVER_ERROR',
+ message: error.message,
+ cause: e,
+ });
+ }
}),
});