diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx index fd36dfa4..fb289f37 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx @@ -248,7 +248,7 @@ export const SidebarChat = () => { setInstructions(''); formRef.current?.reset(); // reset the form's text when clear instructions or unexpected behavior happens threadsStateService.setStaging([]) // clear staging - setLatestError('') + setLatestError(null) } diff --git a/src/vs/workbench/contrib/void/browser/react/src/util/ErrorDisplay.tsx b/src/vs/workbench/contrib/void/browser/react/src/util/ErrorDisplay.tsx index b51545c2..fee117cb 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/util/ErrorDisplay.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/util/ErrorDisplay.tsx @@ -3,30 +3,43 @@ import { AlertCircle, ChevronDown, ChevronUp, X } from 'lucide-react'; import { getCmdKey } from '../../../getCmdKey.js'; -const opaqueMessage = `\ -Unfortunately, Void can't see the full error. However, you should be able to find more details by pressing ${getCmdKey()}+Shift+P, typing "Toggle Developer Tools", and looking at the console.\n -This error often means you have an incorrect API key. If you're self-hosting your own server, it might mean your CORS headers are off, and you should make sure your server's response has the header "Access-Control-Allow-Origins" set to "*", or at least allows "vscode-file://vscode-app".` +// const opaqueMessage = `\ +// Unfortunately, Void can't see the full error. However, you should be able to find more details by pressing ${getCmdKey()}+Shift+P, typing "Toggle Developer Tools", and looking at the console.\n +// This error often means you have an incorrect API key. If you're self-hosting your own server, it might mean your CORS headers are off, and you should make sure your server's response has the header "Access-Control-Allow-Origins" set to "*", or at least allows "vscode-file://vscode-app".` +// if ((error instanceof Error) && (error.cause + '').includes('TypeError: Failed to fetch')) { +// e = error as any +// e['Void Team'] = opaqueMessage +// } + + +type Details = { + message: string, + name: string, + // stack: string | null, + cause: string | null, + code: string | null, + additional: Record +} // Get detailed error information const getErrorDetails = (error: unknown) => { - let details: { message: string, name: string, stack: string | null, cause: string | null, code: string | null, additional: Record }; + let details: Details; let e: Error & { [other: string]: undefined | any } - - // If fetch() fails, it gives an opaque message. We add extra details to the error. - if ((error instanceof Error) && (error.cause + '').includes('TypeError: Failed to fetch')) { - e = error as any - e['Void Team'] = opaqueMessage - } - else if (error instanceof Error) { + if (error instanceof Error) { e = error } + // sometimes error is an object but not an Error + else if (typeof error === 'object') { + e = new Error('More details below.', { cause: JSON.stringify(error) }) + } else { e = new Error(String(error)) } + // console.log('error display', JSON.stringify(e)) const message = e.message && e.error ? (e.message + ':\n' + e.error) @@ -35,7 +48,7 @@ const getErrorDetails = (error: unknown) => { details = { name: e.name || 'Error', message: message, - stack: e.stack || null, + // stack: e.stack || null, // can we remove this? it looks awful and not sure stack is ever useful cause: e.cause ? String(e.cause) : null, code: e.code || null, additional: {} @@ -57,7 +70,7 @@ export const ErrorDisplay = ({ showDismiss = true, className = '' }: { - error: Error | string, + error: Error | object | string, onDismiss: (() => void) | null, showDismiss?: boolean, className?: string @@ -65,7 +78,7 @@ export const ErrorDisplay = ({ const [isExpanded, setIsExpanded] = useState(false); const details = getErrorDetails(error); - const hasDetails = details.stack || details.cause || Object.keys(details.additional).length > 0; + const hasDetails = details.cause || Object.keys(details.additional).length > 0; return (
@@ -132,15 +145,14 @@ export const ErrorDisplay = ({
)} - - {details.stack && ( + {/* {details.stack && (
Stack Trace:
 								{details.stack}
 							
- )} + )} */} )}