-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathErrorLook.tsx
More file actions
64 lines (58 loc) · 1.5 KB
/
ErrorLook.tsx
File metadata and controls
64 lines (58 loc) · 1.5 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
63
64
import { lighten } from 'polished';
import styled from 'styled-components';
import React from 'react';
import { FaExclamationTriangle } from 'react-icons/fa';
import { Column } from './Row';
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>
<Column>
<CodeBlock>{error.message}</CodeBlock>
{showTrace && (
<>
Stack trace:
<CodeBlock
style={{
maxHeight: '10rem',
}}
>
{error.stack}
</CodeBlock>
</>
)}
</Column>
</ErrorLookBig>
);
}
const ErrorLookBig = styled.div`
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)};
background-color: ${p => p.theme.colors.bg1};
`;
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;
`;