diff --git a/ui/shared/monaco/CodeEditor.tsx b/ui/shared/monaco/CodeEditor.tsx index 89f230e582..31182c8a9a 100644 --- a/ui/shared/monaco/CodeEditor.tsx +++ b/ui/shared/monaco/CodeEditor.tsx @@ -1,5 +1,5 @@ import type { SystemStyleObject } from '@chakra-ui/react'; -import { Box, useColorMode, Flex, useToken } from '@chakra-ui/react'; +import { Box, useColorMode, Flex, useToken, Center } from '@chakra-ui/react'; import type { EditorProps } from '@monaco-editor/react'; import MonacoEditor from '@monaco-editor/react'; import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; @@ -11,6 +11,7 @@ import type { SmartContractExternalLibrary } from 'types/api/contract'; import useClientRect from 'lib/hooks/useClientRect'; import useIsMobile from 'lib/hooks/useIsMobile'; import isMetaKey from 'lib/isMetaKey'; +import ErrorBoundary from 'ui/shared/ErrorBoundary'; import CodeEditorBreadcrumbs from './CodeEditorBreadcrumbs'; import CodeEditorLoading from './CodeEditorLoading'; @@ -207,6 +208,10 @@ const CodeEditor = ({ data, remappings, libraries, language, mainFile }: Props) }, }), [ editorWidth, themeColors, borderRadius ]); + const renderErrorScreen = React.useCallback(() => { + return
Oops! Something went wrong!
; + }, [ themeColors ]); + if (data.length === 1) { const sx = { ...containerSx, @@ -220,15 +225,17 @@ const CodeEditor = ({ data, remappings, libraries, language, mainFile }: Props) return ( - } - /> + + } + /> + ); } @@ -247,34 +254,36 @@ const CodeEditor = ({ data, remappings, libraries, language, mainFile }: Props) onKeyDown={ handleKeyDown } onKeyUp={ handleKeyUp } > - - + + + + } + /> + + - - } - /> - - + ); };