1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

Adding error message if the provider cannot be reached

This commit is contained in:
Jamie Hewitt 2023-01-05 14:57:10 +00:00
parent 686f4d1803
commit e9c72bcba8

View File

@ -4,7 +4,7 @@ import FileInfo from './Info'
import UrlInput from '../URLInput' import UrlInput from '../URLInput'
import { InputProps } from '@shared/FormInput' import { InputProps } from '@shared/FormInput'
import { getFileInfo } from '@utils/provider' import { getFileInfo } from '@utils/provider'
import { LoggerInstance } from '@oceanprotocol/lib' import { LoggerInstance, ProviderInstance } from '@oceanprotocol/lib'
import { useAsset } from '@context/Asset' import { useAsset } from '@context/Asset'
export default function FilesInput(props: InputProps): ReactElement { 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.' '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) const checkedFile = await getFileInfo(url, providerUrl, storageType)