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

Commit409df47

Browse files
committed
test custom error page
1 parent69190ec commit409df47

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

‎typings/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export interface MachineStateSchema {
7474
Initialize:{}
7575
Summary:{}
7676
LoadNext:{}
77+
Error:{}
7778
Level:{
7879
states:{
7980
Load:{}

‎web-app/src/Routes.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ const Routes = () => {
2222
<LoadingPagetext="Launching..."context={{}asCR.MachineContext}/>
2323
</Route>
2424
<Routepath={'Start.Error'}>
25-
<div>Error</div>
25+
<div>Something went wrong wrong</div>
2626
</Route>
2727
<Routepath="Start.SelectTutorial">
2828
<NewPagesend={tempSend}context={{}asCR.MachineContext}/>
2929
</Route>
3030
<Routepath="Start.ContinueTutorial">
3131
<ContinuePagesend={tempSend}context={{}asCR.MachineContext}/>
3232
</Route>
33+
<Routepath={'Tutorial.Error'}>
34+
<div>Something went wrong wrong</div>
35+
</Route>
3336
<Routepath="Tutorial.Initialize">
3437
<LoadingPagetext="Initializing..."context={{}asCR.MachineContext}/>
3538
</Route>

‎web-app/src/components/Error/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,28 @@ const styles = {
99
color:'#D8000C',
1010
backgroundColor:'#FFBABA',
1111
padding:'1rem',
12+
width:'100%',
13+
height:'100%',
1214
},
1315
}
1416

1517
interfaceProps{
16-
error:ApolloError
18+
error?:ApolloError
1719
}
1820

1921
constErrorView=({ error}:Props)=>{
2022
// log error
2123
React.useEffect(()=>{
22-
console.log(error)
23-
onError(error)
24+
if(error){
25+
console.log(error)
26+
onError(error)
27+
}
2428
},[])
2529

30+
if(!error){
31+
returnnull
32+
}
33+
2634
return(
2735
<divcss={styles.container}>
2836
<h1>Error</h1>

‎web-app/src/services/state/machine.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,14 @@ export const createMachine = (options: any) => {
123123
}),
124124
},
125125
onError:{
126-
target:'Summary',
126+
target:'Error',
127127
actions:assign({
128128
error:(context,event)=>event.data,
129129
}),
130130
},
131131
},
132132
},
133+
Error:{},
133134
Summary:{
134135
on:{
135136
LOAD_TUTORIAL:{

‎web-app/src/services/state/services/authenticate.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,26 @@ export async function authenticate(context: CR.MachineContext): Promise<any> {
3535
// let message
3636
if(error.message.match(/Networkerror:/)){
3737
returnPromise.reject({
38-
error:{
39-
title:'Network Error',
40-
description:'Make sure you have an Internet connection. Restart and try again',
41-
},
38+
title:'Network Error',
39+
description:'Make sure you have an Internet connection. Restart and try again',
4240
})
4341
}else{
4442
returnPromise.reject({
45-
error:{
46-
title:'Server Error',
47-
description:error.message,
48-
},
43+
title:'Server Error',
44+
description:error.message,
4945
})
5046
}
5147
})
5248

5349
if(!result||!result.data){
54-
consterror=newError('Authentication request responded with no data')
50+
constmessage='Authentication request responded with no data'
51+
consterror=newError()
5552
console.log(error)
5653
onError(error)
57-
return
54+
returnPromise.reject({
55+
title:message,
56+
description:'Something went wrong.',
57+
})
5858
}
5959
const{ token}=result.data.editorLogin
6060
// add token to headers

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp