-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathError.js
More file actions
60 lines (57 loc) · 1.62 KB
/
Error.js
File metadata and controls
60 lines (57 loc) · 1.62 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React from 'react';
import PropTypes from 'prop-types';
const isDev = process.env.NODE_ENV !== 'production';
const color = '#83CD29';
const msgStyle = { backgroundColor: '#222', color, padding: 5, borderRadius: 4, fontSize: 15 };
export const ErrorMsg = ({ title, msg, error }) => (
<div
style={{
width: '100vw',
height: '100vh',
backgroundColor: 'black',
position: 'fixed',
top: 0,
left: 0,
}}
>
<div
style={{
display: 'flex',
flexDirection: 'column',
position: 'fixed',
top: '50vh',
left: '50vw',
transform: 'translate(-50%, -50%)',
width: 'fit-contents',
height: 'auto',
padding: 10,
border: `2px solid ${color}`,
borderRadius: 8,
fontFamily: 'sans-serif',
boxShadow: `0 2px 1px rgba(0,0,0,0.02),
0 4px 2px rgba(255,0,0,0.02),
0 8px 4px rgba(255,0,0,0.02),
0 16px 8px rgba(255,0,0,0.02),
0 32px 16px rgba(255,0,0,0.02)`,
}}
>
<h2 style={{ color, margin: 0, marginBottom: 10 }}>{title || '🐛 Reactend Error'}</h2>
{isDev && (
<>
<code style={msgStyle}>{msg}</code>
<br />
<b style={{ color, marginBottom: 5 }}>message:</b>
{error.message && <code style={msgStyle}>{error.message}</code>}
<br />
<b style={{ color, marginBottom: 5 }}>stack:</b>
{error.stack && <code style={msgStyle}>{error.stack}</code>}
</>
)}
</div>
</div>
);
Error.propTypes = {
title: PropTypes.string,
msg: PropTypes.string.isRequired,
error: PropTypes.any,
};