From e9c72bcba82bdb5300943bfdd78c3839af7acfda Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Thu, 5 Jan 2023 14:57:10 +0000 Subject: [PATCH] Adding error message if the provider cannot be reached --- .../@shared/FormInput/InputElement/FilesInput/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/@shared/FormInput/InputElement/FilesInput/index.tsx b/src/components/@shared/FormInput/InputElement/FilesInput/index.tsx index 6f159280e..482cecb62 100644 --- a/src/components/@shared/FormInput/InputElement/FilesInput/index.tsx +++ b/src/components/@shared/FormInput/InputElement/FilesInput/index.tsx @@ -4,7 +4,7 @@ import FileInfo from './Info' import UrlInput from '../URLInput' import { InputProps } from '@shared/FormInput' import { getFileInfo } from '@utils/provider' -import { LoggerInstance } from '@oceanprotocol/lib' +import { LoggerInstance, ProviderInstance } from '@oceanprotocol/lib' import { useAsset } from '@context/Asset' export default function FilesInput(props: InputProps): ReactElement { @@ -31,6 +31,13 @@ export default function FilesInput(props: InputProps): ReactElement { 'Google Drive is not a supported hosting service. Please use an alternative.' ) } + // Check if provider is a valid provider + const isValid = await ProviderInstance.isValidProvider(field.value.url) + + if (!isValid) + throw Error( + '✗ Provider cannot be reached, please check status at https://status.oceanprotocol.com and try again later.' + ) const checkedFile = await getFileInfo(url, providerUrl, storageType)