Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: added error boundary#1602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Kira-Pilot merged 9 commits intomainfromadd-error-boundary/kira-pilot
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
add body txt and standardize btn size
  • Loading branch information
@Kira-Pilot
Kira-Pilot committedMay 19, 2022
commit59be45a0a14419d95e8e5972fa8ad66216223971
2 changes: 2 additions & 0 deletionssite/src/components/CodeBlock/CodeBlock.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,8 @@ export const CodeBlock: React.FC<CodeBlockProps> = ({ lines, ctas, className = "
const useStyles = makeStyles((theme) => ({
root: {
minHeight: 156,
maxHeight: 240,
overflowY: "scroll",
background: theme.palette.background.default,
color: theme.palette.text.primary,
fontFamily: MONOSPACE_FONT_FAMILY,
Expand Down
2 changes: 2 additions & 0 deletionssite/src/components/RuntimeErrorState/ReportButtons.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,12 +59,14 @@ const useStyles = makeStyles((theme) => ({
marginLeft: 0,
flex: theme.spacing(1),
textTransform: "uppercase",
fontSize: theme.typography.button.fontSize,
},

copyButton: {
width: "100%",
marginRight: theme.spacing(1),
backgroundColor: theme.palette.primary.main,
textTransform: "uppercase",
fontSize: theme.typography.button.fontSize,
},
}))
34 changes: 31 additions & 3 deletionssite/src/components/RuntimeErrorState/RuntimeErrorState.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,13 +2,17 @@ import Box from "@material-ui/core/Box"
import { makeStyles } from "@material-ui/core/styles"
import ErrorOutlineIcon from "@material-ui/icons/ErrorOutline"
import React, { useEffect, useReducer } from "react"
import { Link } from "react-router-dom"
import { mapStackTrace } from "sourcemapped-stacktrace"
import { Margins } from "../Margins/Margins"
import { Section } from "../Section/Section"
import { Typography } from "../Typography/Typography"
import { reducer, RuntimeErrorReport, stackTraceAvailable, stackTraceUnavailable } from "./RuntimeErrorReport"

const Language = {
title: "Coder encountered an error",
body: "Please copy the crash log using the button below and",
link: "send it to us.",
}

interface RuntimeErrorStateProps {
Expand All@@ -20,7 +24,6 @@ interface RuntimeErrorStateProps {
*/
const ErrorStateTitle = () => {
const styles = useStyles()

return (
<Box className={styles.title} display="flex" alignItems="center">
<ErrorOutlineIcon />
Expand All@@ -29,6 +32,28 @@ const ErrorStateTitle = () => {
)
}

/**
* A description for our error boundary UI
*/
const ErrorStateDescription = () => {
const styles = useStyles()
return (
<Typography variant="body2" color="textSecondary">
{Language.body}&nbsp;
<Link
to="#"
onClick={(e) => {
window.location.href = "mailto:support@coder.com"
e.preventDefault()
}}
className={styles.link}
>
{Language.link}
</Link>
</Typography>
)
}

/**
* An error UI that is displayed when our error boundary (ErrorBoundary.tsx) is triggered
*/
Expand All@@ -47,7 +72,7 @@ export const RuntimeErrorState: React.FC<RuntimeErrorStateProps> = ({ error }) =
return (
<Box display="flex" flexDirection="column">
<Margins>
<Section className={styles.reportContainer} title={<ErrorStateTitle />}>
<Section className={styles.reportContainer} title={<ErrorStateTitle />} description={<ErrorStateDescription />}>
<RuntimeErrorReport error={reportState.error} mappedStack={reportState.mappedStack} />
</Section>
</Margins>
Expand All@@ -65,7 +90,10 @@ const useStyles = makeStyles((theme) => ({
color: theme.palette.error.main,
},
},

link: {
textDecoration: "none",
color: theme.palette.primary.main,
},
reportContainer: {
display: "flex",
justifyContent: "center",
Expand Down
2 changes: 0 additions & 2 deletionssite/src/components/Stack/Stack.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,8 +14,6 @@ const useStyles = makeStyles((theme) => ({
}))

export const Stack: React.FC<StackProps> = ({ children, spacing = 2 }) => {
throw new Error("uh oh")

const styles = useStyles({ spacing })
return <div className={styles.stack}>{children}</div>
}

[8]ページ先頭

©2009-2025 Movatter.jp