feat: enhance error handling and add new search feature
- Add support for `PREVIEW_CONSOLE_ERROR` in WebContainer error handling - Introduce new Search component for text search functionality - Extend `ScrollPosition` interface to include `line` and `column` - Implement scroll-to-line functionality in CodeMirrorEditor - Add tab-based navigation for files and search in EditorPanel This commit introduces several enhancements to the editor, including improved error handling, better scrolling capabilities, and a new search feature. The changes are focused on improving the user experience and adding new functionality to the editor components.
This commit is contained in:
@@ -39,12 +39,27 @@ if (!import.meta.env.SSR) {
|
||||
console.log('WebContainer preview message:', message);
|
||||
|
||||
// Handle both uncaught exceptions and unhandled promise rejections
|
||||
if (message.type === 'PREVIEW_UNCAUGHT_EXCEPTION' || message.type === 'PREVIEW_UNHANDLED_REJECTION') {
|
||||
if (
|
||||
message.type === 'PREVIEW_UNCAUGHT_EXCEPTION' ||
|
||||
message.type === 'PREVIEW_UNHANDLED_REJECTION' ||
|
||||
message.type === 'PREVIEW_CONSOLE_ERROR'
|
||||
) {
|
||||
const isPromise = message.type === 'PREVIEW_UNHANDLED_REJECTION';
|
||||
const isConsoleError = message.type === 'PREVIEW_CONSOLE_ERROR';
|
||||
const title = isPromise
|
||||
? 'Unhandled Promise Rejection'
|
||||
: isConsoleError
|
||||
? 'Console Error'
|
||||
: 'Uncaught Exception';
|
||||
workbenchStore.actionAlert.set({
|
||||
type: 'preview',
|
||||
title: isPromise ? 'Unhandled Promise Rejection' : 'Uncaught Exception',
|
||||
description: message.message,
|
||||
title,
|
||||
description:
|
||||
'message' in message
|
||||
? message.message
|
||||
: 'args' in message && Array.isArray(message.args) && message.args.length > 0
|
||||
? message.args[0]
|
||||
: 'Unknown error',
|
||||
content: `Error occurred at ${message.pathname}${message.search}${message.hash}\nPort: ${message.port}\n\nStack trace:\n${cleanStackTrace(message.stack || '')}`,
|
||||
source: 'preview',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user