-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathErrorLook.tsx
More file actions
62 lines (56 loc) · 1.52 KB
/
ErrorLook.tsx
File metadata and controls
62 lines (56 loc) · 1.52 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
61
62
import { lighten } from 'polished';
import styled from 'styled-components';
import React from 'react';
import { Details } from './Details';
import { FaExclamationTriangle } from 'react-icons/fa';
export const ErrorLook = styled.span`
color: ${props => props.theme.colors.alert};
font-family: monospace;
`;
export interface ErrorBlockProps {
error: Error;
showTrace?: boolean;
}
export function ErrorBlock({ error, showTrace }: ErrorBlockProps): JSX.Element {
return (
<ErrorLookBig>
<BiggerText>
<FaExclamationTriangle />
Something went wrong
</BiggerText>
<Details title={<span>Show Details</span>}>
<pre>
<CodeBlock>{error.message}</CodeBlock>
</pre>
{showTrace && (
<>
<span>Stack trace:</span>
<pre>
<CodeBlock>{error.stack}</CodeBlock>
</pre>
</>
)}
</Details>
</ErrorLookBig>
);
}
const ErrorLookBig = styled.div`
background-color: ${p => lighten(0.4, p.theme.colors.alert)};
color: ${p => p.theme.colors.alert};
font-size: 1rem;
padding: ${p => p.theme.margin}rem;
border-radius: ${p => p.theme.radius};
border: 1px solid ${p => lighten(0.2, p.theme.colors.alert)};
`;
const CodeBlock = styled.code`
white-space: pre-wrap;
border-radius: ${p => p.theme.radius};
padding: ${p => p.theme.margin}rem;
background-color: ${p => p.theme.colors.bg};
`;
const BiggerText = styled.p`
font-size: 1.3rem;
display: flex;
align-items: center;
gap: 1ch;
`;