-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathErrorMessage.jsx
More file actions
42 lines (40 loc) · 1.15 KB
/
ErrorMessage.jsx
File metadata and controls
42 lines (40 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
export default function ErrorMessage({ message, error, onRetry }) {
const errorText = message || error?.toString() || "An error occurred";
if (!message && !error) return null;
return (
<div className="error" style={{
padding: '16px',
margin: '16px 0',
backgroundColor: '#fee',
border: '1px solid #fcc',
borderRadius: '8px',
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
gap: '12px'
}}>
<span style={{ flex: 1 }}>
⚠️ <strong>Error:</strong> {errorText}
</span>
{onRetry && (
<button
onClick={onRetry}
style={{
padding: '8px 16px',
backgroundColor: '#ff4444',
color: 'white',
border: 'none',
borderRadius: '6px',
cursor: 'pointer',
fontWeight: 'bold',
transition: 'background-color 0.2s',
}}
onMouseOver={(e) => e.target.style.backgroundColor = '#cc0000'}
onMouseOut={(e) => e.target.style.backgroundColor = '#ff4444'}
>
🔄 Retry
</button>
)}
</div>
);
}