From 4c09176b8ddf3f7c0ac2f89c61e5a82f3c01c148 Mon Sep 17 00:00:00 2001 From: 1M4nt0 Date: Mon, 16 Oct 2023 15:18:32 +0200 Subject: [PATCH] fix: write more concise messages about ipfs latency errors --- .../wagmi/src/hooks/api/useCreateCredential.ts | 5 +++-- packages/wagmi/src/hooks/web3/useCreateCourse.ts | 15 ++++----------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/wagmi/src/hooks/api/useCreateCredential.ts b/packages/wagmi/src/hooks/api/useCreateCredential.ts index fd5cd78..6910364 100644 --- a/packages/wagmi/src/hooks/api/useCreateCredential.ts +++ b/packages/wagmi/src/hooks/api/useCreateCredential.ts @@ -42,8 +42,9 @@ export const useCreateCredential = () => { }) if (!response.ok) { - const responseJSON = await response.json() - throw new Error(responseJSON.message) + throw new Error( + 'There is a problem creating credential. This may be due to high latency of the ipfs node. Please try again in a few minutes.', + ) } mutate( diff --git a/packages/wagmi/src/hooks/web3/useCreateCourse.ts b/packages/wagmi/src/hooks/web3/useCreateCourse.ts index 5268f37..b2b5b52 100644 --- a/packages/wagmi/src/hooks/web3/useCreateCourse.ts +++ b/packages/wagmi/src/hooks/web3/useCreateCourse.ts @@ -106,7 +106,9 @@ export function useCreateCourse({ }) if (!uploadMetadataResponse.ok) { - throw new Error('Error uploading course metadata to IPFS') + throw new Error( + 'There is a problem uploading course metadata. This may be due to high latency of the ipfs node. Please try again in a few minutes.', + ) } setStep(1) @@ -121,16 +123,7 @@ export function useCreateCourse({ !uploadMetadataResponseJson.data?.metadata.url ) { throw new Error( - 'There is a problem uploading your metadata. Try again.', - ) - } - const metadataResponse = await fetch( - uploadMetadataResponseJson.data.metadata.url, - ) - - if (!metadataResponse.ok) { - throw new Error( - 'There is a problem uploading your metadata. Try again.', + 'There is a problem uploading your uploaded course metadata. Please try again in a few minutes.', ) }