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

Commitb2fcd7a

Browse files
committed
add error component
1 parent64837c0 commitb2fcd7a

File tree

4 files changed

+54
-6
lines changed

4 files changed

+54
-6
lines changed

‎package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
},
3838
"devDependencies": {
3939
"@types/dotenv":"^6.1.1",
40+
"@types/graphql":"^14.2.3",
4041
"@types/mocha":"^5.2.7",
4142
"@types/node":"^12.7.1",
4243
"concurrently":"^4.1.1",
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import*asReactfrom'react'
2+
import{ApolloError}from'apollo-boost'
3+
import{GraphQLError}from'graphql'
4+
5+
conststyles={
6+
container:{
7+
color:'#D8000C',
8+
backgroundColor:'#FFBABA',
9+
padding:'1rem',
10+
},
11+
}
12+
13+
interfaceProps{
14+
error:ApolloError
15+
}
16+
17+
constErrorView=({ error}:Props)=>{
18+
console.log('ERROR:',error)
19+
return(
20+
<divstyle={styles.container}>
21+
<h1>Error</h1>
22+
{error.graphQLErrors&&(
23+
<div>
24+
{error.graphQLErrors.map(({ message, locations, path}:GraphQLError)=>(
25+
<h5>
26+
<b>[GraphQL error]:</b> Message:{message}, Location:{locations}, Path:{path}
27+
</h5>
28+
))}
29+
</div>
30+
)}
31+
{error.networkError&&(
32+
<h5>
33+
<b>[Network error]:</b>{error.networkError.message}
34+
</h5>
35+
)}
36+
{error.extraInfo&&(
37+
<p>
38+
<b>[Extra info]:</b>{JSON.stringify(error.extraInfo)}
39+
</p>
40+
)}
41+
</div>
42+
)
43+
}
44+
45+
exportdefaultErrorView

‎web-app/src/containers/New/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as T from '../../../../typings/graphql'
55
importqueryTutorialsfrom'./queryTutorials'
66
import{send}from'../../utils/vscode'
77
importLoadingPagefrom'../LoadingPage'
8+
importErrorViewfrom'../../components/Error'
89
importTutorialListfrom'../../components/TutorialList'
910

1011
interfaceProps{
@@ -28,12 +29,7 @@ const NewPageContainer = () => {
2829
}
2930

3031
if(error){
31-
return(
32-
<div>
33-
<h5>{error.message}</h5>
34-
<p>{JSON.stringify(error,null,2)}</p>
35-
</div>
36-
)
32+
return<ErrorViewerror={error}/>
3733
}
3834

3935
return(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp