Improve error message logging from electron (#7130)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { Button } from './ui/button';
|
||||
import { AlertTriangle } from 'lucide-react';
|
||||
import { errorMessage } from '../utils/conversionUtils';
|
||||
import { errorMessage, formatErrorForLogging } from '../utils/conversionUtils';
|
||||
import { trackErrorWithContext, trackEvent, getErrorType } from '../utils/analytics';
|
||||
|
||||
function getCurrentPage(): string {
|
||||
@@ -10,7 +10,8 @@ function getCurrentPage(): string {
|
||||
|
||||
// Capture unhandled promise rejections
|
||||
window.addEventListener('unhandledrejection', (event) => {
|
||||
window.electron.logInfo(`[UNHANDLED REJECTION] ${event.reason}`);
|
||||
const reasonStr = formatErrorForLogging(event.reason);
|
||||
window.electron.logInfo(`[UNHANDLED REJECTION] ${reasonStr}`);
|
||||
trackErrorWithContext(event.reason, {
|
||||
component: 'global',
|
||||
page: getCurrentPage(),
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '../../ui/dialog';
|
||||
import { errorMessage } from '../../../utils/conversionUtils';
|
||||
|
||||
const HelpText = () => (
|
||||
<div className="text-sm flex-col space-y-4 text-text-muted">
|
||||
@@ -39,7 +40,7 @@ const HelpText = () => (
|
||||
|
||||
const ErrorDisplay = ({ error }: { error: Error }) => (
|
||||
<div className="text-sm text-text-muted">
|
||||
<div className="text-red-600">Error reading .goosehints file: {JSON.stringify(error)}</div>
|
||||
<div className="text-red-600">Error reading .goosehints file: {errorMessage(error)}</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
|
||||
@@ -19,20 +19,7 @@ import { useModelAndProvider } from '../../../ModelAndProviderContext';
|
||||
import { AlertTriangle, LogIn } from 'lucide-react';
|
||||
import { ProviderDetails, removeCustomProvider, configureProviderOauth } from '../../../../api';
|
||||
import { Button } from '../../../../components/ui/button';
|
||||
|
||||
const formatErrorMessage = (error: unknown): string => {
|
||||
if (error instanceof Error) {
|
||||
return error.message;
|
||||
}
|
||||
if (typeof error === 'string') {
|
||||
return error;
|
||||
}
|
||||
try {
|
||||
return JSON.stringify(error);
|
||||
} catch {
|
||||
return String(error);
|
||||
}
|
||||
};
|
||||
import { errorMessage } from '../../../../utils/conversionUtils';
|
||||
|
||||
interface ProviderConfigurationModalProps {
|
||||
provider: ProviderDetails;
|
||||
@@ -87,7 +74,7 @@ export default function ProviderConfigurationModal({
|
||||
onClose();
|
||||
}
|
||||
} catch (err) {
|
||||
setError(`OAuth login failed: ${formatErrorMessage(err)}`);
|
||||
setError(`OAuth login failed: ${errorMessage(err)}`);
|
||||
} finally {
|
||||
setIsOAuthLoading(false);
|
||||
}
|
||||
@@ -130,7 +117,7 @@ export default function ProviderConfigurationModal({
|
||||
onClose();
|
||||
}
|
||||
} catch (error) {
|
||||
setError(formatErrorMessage(error));
|
||||
setError(errorMessage(error));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user