From cbd816197e350af22fd830de524c896aba10904b Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 23 Jun 2022 13:15:47 +0530 Subject: [PATCH] handle wrong github url --- libs/remix-ui/workspace/src/lib/actions/index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 208ebd139f..b0cd59bbc2 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -103,10 +103,15 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. } } else if (route.endsWith('.sol')) { if (route.includes('blob')) route = route.replace('/blob', '') - const response: AxiosResponse = await axios.get(`https://raw.githubusercontent.com${route}`) - let content - if (response.status === 200) { - content = response.data + let response: AxiosResponse + try { + response = await axios.get(`https://raw.githubusercontent.com${route}`) + } catch (error) { + plugin.call('notification', 'toast', `cound not find ${route} on GitHub`) + await basicWorkspaceInit(workspaces, workspaceProvider) + } + if (response && response.status === 200) { + const content = response.data await createWorkspaceTemplate('github-code-sample', 'code-template') plugin.setWorkspace({ name: 'github-code-sample', isLocalhost: false }) dispatch(setCurrentWorkspace('github-code-sample'))