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

Commit2b73484

Browse files
committed
standardize error messages
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent345770f commit2b73484

File tree

13 files changed

+65
-181
lines changed

13 files changed

+65
-181
lines changed

‎errors/WorkspaceNotEmpty.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
###Select An Empty VSCode Workspace
2+
3+
Start a project in an empty folder.
4+
5+
Once selected, the extension will close and need to be re-started.

‎src/actions/tutorialConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const tutorialConfig = async ({ config, alreadyConfigured }: TutorialConfigParam
1717
(error:Error):E.ErrorMessage=>({
1818
type:'GitNotFound',
1919
message:error.message,
20+
actions:[{label:'Retry',transition:''}],
2021
}),
2122
)
2223

@@ -29,6 +30,7 @@ const tutorialConfig = async ({ config, alreadyConfigured }: TutorialConfigParam
2930
(error:Error):E.ErrorMessage=>({
3031
type:'FailedToConnectToGitRepo',
3132
message:error.message,
33+
actions:[{label:'Retry',transition:''}],
3234
}),
3335
)
3436

‎src/channel/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,21 @@ class Channel implements Channel {
125125
// 1. check workspace is selected
126126
constisEmptyWorkspace=awaitcheckWorkspaceEmpty(this.workspaceRoot.uri.path)
127127
if(!isEmptyWorkspace){
128-
this.send({type:'NOT_EMPTY_WORKSPACE'})
128+
consterror:E.ErrorMessage={
129+
type:'WorkspaceNotEmpty',
130+
message:'',
131+
actions:[
132+
{
133+
label:'Open Workspace',
134+
transition:'REQUEST_WORKSPACE',
135+
},
136+
{
137+
label:'Check Again',
138+
transition:'RETRY',
139+
},
140+
],
141+
}
142+
this.send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})
129143
return
130144
}
131145
// 2. check Git is installed.

‎typings/error.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ export type ErrorMessageType =
66
|'FailedToConnectToGitRepo'
77
|'GitProjectAlreadyExists'
88
|'GitRemoteAlreadyExists'
9+
|'WorkspaceNotEmpty'
10+
11+
exporttypeErrorAction={
12+
label:string
13+
transition:string
14+
}
915

1016
exporttypeErrorMessage={
1117
type:ErrorMessageType
1218
message:string
1319
display?:ErrorMessageView
20+
actions?:ErrorAction[]
1421
}

‎typings/index.d.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import*asEfrom'./error'
12
import*asTTfrom'./tutorial'
23

34
exporttypeProgressStatus='ACTIVE'|'COMPLETE'|'INCOMPLETE'
@@ -37,11 +38,6 @@ export interface Environment {
3738
token:string
3839
}
3940

40-
exportinterfaceErrorMessage{
41-
title:string
42-
description?:string
43-
}
44-
4541
exportinterfaceTestStatus{
4642
type:'success'|'warning'|'error'|'loading'
4743
title:string
@@ -50,7 +46,7 @@ export interface TestStatus {
5046

5147
exportinterfaceMachineContext{
5248
env:Environment
53-
error:ErrorMessage|null
49+
error:E.ErrorMessage|null
5450
tutorial:TT.Tutorial|null
5551
position:Position
5652
progress:Progress
@@ -72,9 +68,6 @@ export interface MachineStateSchema {
7268
LoadStoredTutorial:{}
7369
Start:{}
7470
ValidateSetup:{}
75-
NonEmptyWorkspace:{}
76-
GitNotInstalled:{}
77-
GitRemoteFailed:{}
7871
SelectTutorial:{}
7972
SetupNewTutorial:{}
8073
StartNewTutorial:{}

‎web-app/src/Routes.tsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,47 @@
11
import*asReactfrom'react'
22
importuseRouterfrom'./components/Router'
33
importWorkspacefrom'./components/Workspace'
4+
importErrorViewfrom'./components/Error'
45
importLoadingPagefrom'./containers/Loading'
56
importStartPagefrom'./containers/Start'
67
importSelectTutorialPagefrom'./containers/SelectTutorial'
78
importCompletedPagefrom'./containers/Tutorial/CompletedPage'
89
importLevelSummaryPagefrom'./containers/Tutorial/LevelPage'
9-
importSelectEmptyWorkspacefrom'./containers/Check/SelectWorkspace'
10-
importGitInstalledfrom'./containers/Check/GitInstalled'
11-
importGitRemoteFailedfrom'./containers/Check/GitRemoteFailed'
1210

1311
constRoutes=()=>{
1412
const{ context, send, Router, Route}=useRouter()
13+
14+
// TODO: handle only full page errors
15+
if(context.error){
16+
return(
17+
<Workspace>
18+
<ErrorViewsend={send}error={context.error}/>
19+
</Workspace>
20+
)
21+
}
22+
1523
return(
1624
<Workspace>
1725
<Router>
1826
{/* Setup */}
1927
<Routepath={['Setup.Startup','Setup.LoadStoredTutorial','Setup.ValidateSetup']}>
20-
<LoadingPagetext="Launching..."context={context}/>
28+
<LoadingPagetext="Launching..."/>
2129
</Route>
2230
<Routepath="Setup.Start">
2331
<StartPagesend={send}context={context}/>
2432
</Route>
2533
<Routepath={['Setup.LoadTutorialSummary','Setup.LoadTutorialData','Setup.SetupNewTutorial']}>
26-
<LoadingPagetext="Loading Tutorial..."context={context}/>
27-
</Route>
28-
<Routepath={['Setup.NonEmptyWorkspace','Setup.RequestEmptyWorkspace']}>
29-
<SelectEmptyWorkspacesend={send}/>
30-
</Route>
31-
<Routepath="Setup.GitNotInstalled">
32-
<GitInstalledsend={send}/>
34+
<LoadingPagetext="Loading Tutorial..."/>
3335
</Route>
3436
<Routepath="Setup.SelectTutorial">
3537
<SelectTutorialPagesend={send}context={context}/>
3638
</Route>
3739
<Routepath={['Setup.SetupNewTutorial','Setup.StartNewTutorial']}>
38-
<LoadingPagetext="Configuring tutorial..."context={context}/>
39-
</Route>
40-
<Routepath="Setup.GitRemoteFailed">
41-
<GitRemoteFailedsend={send}error={context.error}/>
40+
<LoadingPagetext="Configuring tutorial..."/>
4241
</Route>
4342
{/* Tutorial */}
4443
<Routepath={['Tutorial.LoadNext','Tutorial.Level.Load']}>
45-
<LoadingPagetext="Loading Level..."context={context}/>
44+
<LoadingPagetext="Loading Level..."/>
4645
</Route>
4746
<Routepath="Tutorial.Level">
4847
<LevelSummaryPagesend={send}context={context}/>

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import*asReactfrom'react'
22
import*asEfrom'typings/error'
3+
import*asTfrom'typings'
34
import{css,jsx}from'@emotion/core'
45
importMarkdownfrom'../Markdown'
6+
importButtonfrom'../../components/Button'
57

68
conststyles={
79
container:{
@@ -14,10 +16,11 @@ const styles = {
1416
}
1517

1618
interfaceProps{
17-
error?:E.ErrorMessage
19+
error:E.ErrorMessage
20+
send:(action:T.Action)=>void
1821
}
1922

20-
constErrorMarkdown=({ error}:Props)=>{
23+
constErrorMarkdown=({ error, send}:Props)=>{
2124
React.useEffect(()=>{
2225
if(error){
2326
// log error
@@ -33,6 +36,13 @@ const ErrorMarkdown = ({ error }: Props) => {
3336
<divcss={styles.container}>
3437
<h1>Error</h1>
3538
<Markdown>{error.message}</Markdown>
39+
{/* Actions */}
40+
{error.actions&&
41+
error.actions.map((a)=>(
42+
<Buttontype="secondary"onClick={()=>send({type:a.transition})}>
43+
{a.label}
44+
</Button>
45+
))}
3646
</div>
3747
)
3848
}

‎web-app/src/containers/Check/GitInstalled.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎web-app/src/containers/Check/GitRemoteFailed.tsx

Lines changed: 0 additions & 48 deletions
This file was deleted.

‎web-app/src/containers/Check/SelectWorkspace.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎web-app/src/containers/Loading/LoadingPage.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from 'react'
22
import*asTfrom'typings'
33
import{css,jsx}from'@emotion/core'
44
importLoadingfrom'../../components/Loading'
5-
importMessagefrom'../../components/Message'
65

76
interfaceProps{
87
text:string
@@ -20,15 +19,7 @@ const styles = {
2019
},
2120
}
2221

23-
constLoadingPage=({ text, context}:Props)=>{
24-
const{ error}=context
25-
if(error){
26-
return(
27-
<divcss={styles.page}>
28-
<Messagetype="error"title={error.title}content={error.description}/>
29-
</div>
30-
)
31-
}
22+
constLoadingPage=({ text}:Props)=>{
3223
return(
3324
<divcss={styles.page}>
3425
<Loadingtext={text}/>

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const styles = {
2020
},
2121
}
2222

23-
constLoadingPage=({ text, context}:Props)=>{
23+
constLoadingPage=({ text}:Props)=>{
2424
const[showLoading,setShowHiding]=React.useState(false)
2525

2626
React.useEffect(()=>{
@@ -33,14 +33,6 @@ const LoadingPage = ({ text, context }: Props) => {
3333
}
3434
},[])
3535

36-
if(context&&context.error){
37-
return(
38-
<divcss={styles.page}>
39-
<Messagetype="error"title={context.error.title}content={context.error.description}/>
40-
</div>
41-
)
42-
}
43-
4436
// don't flash loader
4537
if(!showLoading){
4638
returnnull

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp