fix: report API errors (422, 404, 5xx, network) and React errors to Forgejo error reporter

- client.ts: logError() import added, API error interceptor now reports to /api/v1/errors
- ErrorBoundary.tsx: logError() import added, React rendering errors now reported
- 401 (auth) and 403 (permission) errors are NOT reported (expected behavior)
- 422 (validation), 404 (not found), 5xx (server), 0 (network) ARE reported
This commit is contained in:
Agent Zero
2026-07-26 23:45:59 +02:00
parent 99643d25ab
commit 1ba702f6fe
2 changed files with 15 additions and 0 deletions
+13
View File
@@ -1,4 +1,5 @@
import axios, { AxiosError, AxiosRequestConfig, InternalAxiosRequestConfig } from 'axios';
import { logError } from '@/utils/errorLogger';
export interface ApiError {
status: number;
@@ -114,6 +115,18 @@ apiClient.interceptors.response.use(
validationErrors: status === 422 ? extractValidationErrors(data) : undefined,
};
// Report API errors to backend error logger (for Forgejo issue creation)
// Skip 401 (auth) and 403 (permission) — these are expected, not bugs
// Report: 422 (validation), 404 (not found), 5xx (server), 0 (network)
if (status !== 401 && status !== 403) {
logError(apiError.message, {
status,
url: error.config?.url,
method: error.config?.method,
detail: apiError.detail,
});
}
return Promise.reject(apiError);
}
);
@@ -1,4 +1,5 @@
import React from 'react';
import { logError } from '@/utils/errorLogger';
interface ErrorBoundaryProps {
children: React.ReactNode;
@@ -26,6 +27,7 @@ export class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoun
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {
console.error('[ErrorBoundary] Uncaught error:', error, errorInfo);
logError(error, { componentStack: errorInfo.componentStack, source: 'ErrorBoundary' });
}
handleReload = (): void => {