shinkan-jinkendo/frontend/src/ErrorBoundary.jsx
Lars 5b13a0a526
Some checks failed
Deploy Development / deploy (push) Successful in 36s
Test Suite / pytest-backend (push) Successful in 25s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 8s
Test Suite / playwright-tests (push) Failing after 1m43s
chore: refine media path configuration in environment files
- Updated .env.example to clarify SHINKAN_MEDIA_HOST usage for different environments.
- Modified docker-compose files to set default values for SHINKAN_MEDIA_HOST, ensuring consistent media path handling in development and production.
- Enhanced comments for better understanding of media path configurations.
2026-05-08 08:41:27 +02:00

72 lines
2.0 KiB
JavaScript

import React from 'react'
/**
* Fängt Render-Fehler ab — verhindert „weißen Bildschirm“ ohne Hinweis (z. B. nach Deploy/Chaches).
*/
export default class ErrorBoundary extends React.Component {
constructor(props) {
super(props)
this.state = { error: null }
}
static getDerivedStateFromError(error) {
return { error }
}
componentDidCatch(error, info) {
console.error('ErrorBoundary:', error, info?.componentStack)
}
render() {
if (this.state.error) {
const msg = this.state.error?.message || String(this.state.error)
return (
<div
style={{
minHeight: '100vh',
padding: '24px',
fontFamily: 'system-ui, sans-serif',
background: '#f8fafc',
color: '#0f172a',
}}
>
<h1 style={{ fontSize: '1.25rem', marginBottom: '12px' }}>Ein Fehler ist aufgetreten</h1>
<p style={{ marginBottom: '16px', maxWidth: '40rem', lineHeight: 1.5 }}>
Die Oberfläche konnte nicht geladen werden. Details siehe unten oder in der
Browser-Konsole (F12). Nach einem Deploy einen <strong>harten Reload</strong> (Cache leeren)
versuchen.
</p>
<pre
style={{
padding: '12px',
background: '#fff',
border: '1px solid #e2e8f0',
borderRadius: 8,
overflow: 'auto',
fontSize: '0.85rem',
}}
>
{msg}
</pre>
<p style={{ marginTop: '20px' }}>
<button
type="button"
style={{
padding: '10px 16px',
borderRadius: 8,
border: '1px solid #cbd5e1',
background: '#fff',
cursor: 'pointer',
}}
onClick={() => window.location.reload()}
>
Seite neu laden
</button>
</p>
</div>
)
}
return this.props.children
}
}