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

Commit9fdb5df

Browse files
committed
setup better tutorial config errors
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parenta71d857 commit9fdb5df

File tree

10 files changed

+63
-32
lines changed

10 files changed

+63
-32
lines changed

‎src/actions/tutorialConfig.ts

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,39 @@
1-
import*asTfrom'typings'
1+
import*asEfrom'typings/error'
22
import*asTTfrom'typings/tutorial'
33
import*asvscodefrom'vscode'
44
import{COMMANDS}from'../editor/commands'
55
import*asgitfrom'../services/git'
6-
importonErrorfrom'../services/sentry/onError'
76

87
interfaceTutorialConfigParams{
98
config:TT.TutorialConfig
109
alreadyConfigured?:boolean
1110
onComplete?():void
1211
}
1312

14-
consttutorialConfig=async(
15-
{ config, alreadyConfigured}:TutorialConfigParams,
16-
handleError:(msg:T.ErrorMessage)=>void,
17-
)=>{
13+
consttutorialConfig=async({ config, alreadyConfigured}:TutorialConfigParams):Promise<E.ErrorMessage|void>=>{
1814
if(!alreadyConfigured){
1915
// setup git, add remote
20-
awaitgit.initIfNotExists().catch((error)=>{
21-
onError(newError('Git not found'))
22-
// failed to setup git
23-
handleError({
24-
title:error.message,
25-
description:
26-
'Make sure you install Git. See the docs for help https://git-scm.com/book/en/v2/Getting-Started-Installing-Git',
27-
})
16+
awaitgit.initIfNotExists().catch((error:Error)=>{
17+
return{
18+
type:'GitNotFound',
19+
message:error.message,
20+
}
2821
})
2922

30-
try{
31-
awaitgit.checkRemoteConnects(config.repo)
32-
}catch(error){
33-
onError(error)
34-
handleError({title:'Error connecting to Git repo',description:error.message})
35-
}
23+
// verify that internet is connected, remote exists and branch exists
24+
awaitgit.checkRemoteConnects(config.repo).catch((error:Error)=>{
25+
return{
26+
type:'FailedToConnectToGitRepo',
27+
message:error.message,
28+
}
29+
})
3630

3731
// TODO if remote not already set
38-
awaitgit.setupRemote(config.repo.uri).catch((error)=>{
39-
onError(error)
40-
handleError({title:error.message,description:'Remove your current Git project and reload the editor'})
32+
awaitgit.setupCodeRoadRemote(config.repo.uri).catch((error:Error)=>{
33+
return{
34+
type:'GitRemoteAlreadyExists',
35+
message:error.message,
36+
}
4137
})
4238
}
4339

‎src/channel/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import*asTfrom'typings'
22
import*asTTfrom'typings/tutorial'
3+
import*asEfrom'typings/error'
34
import*asvscodefrom'vscode'
45
importsaveCommitfrom'../actions/saveCommit'
56
importsetupActionsfrom'../actions/setupActions'
@@ -86,11 +87,14 @@ class Channel implements Channel {
8687
// setup tutorial config (save watcher, test runner, etc)
8788
awaitthis.context.setTutorial(this.workspaceState,data)
8889

89-
try{
90-
// TODO: better handle errors
91-
awaittutorialConfig({config:data.config})
92-
}catch(error){
93-
this.send({type:'TUTORIAL_CONFIGURE_FAIL',payload:{error:error.message}})
90+
consterror:E.ErrorMessage|void=awaittutorialConfig({config:data.config}).catch((error:Error)=>({
91+
type:'UnknownError',
92+
message:`Location: tutorial config.\n\n${error.message}`,
93+
}))
94+
95+
// has error
96+
if(error&&error.type){
97+
this.send({type:'TUTORIAL_CONFIGURE_FAIL',payload:{ error}})
9498
return
9599
}
96100

‎src/services/git/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ export async function checkRemoteExists(): Promise<boolean> {
145145
}
146146
}
147147

148-
exportasyncfunctionsetupRemote(repo:string):Promise<void>{
148+
exportasyncfunctionsetupCodeRoadRemote(repo:string):Promise<void>{
149149
// check coderoad remote not taken
150150
consthasRemote=awaitcheckRemoteExists()
151151
// git remote add coderoad tutorial
152152
// git fetch coderoad
153153
if(!hasRemote){
154154
awaitaddRemote(repo)
155155
}else{
156-
thrownewError('ARemote is already configured')
156+
thrownewError('ACodeRoad remote is already configured')
157157
}
158158
}

‎tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"emitDecoratorMetadata":true,
2121
"paths": {
2222
"typings": ["../typings/index.d.ts"],
23-
"typings/tutorial": ["../typings/tutorial.d.ts"]
23+
"typings/tutorial": ["../typings/tutorial.d.ts"],
24+
"typings/error": ["../typings/error.d.ts"]
2425
},
2526
"allowJs":true,
2627
"removeComments":true

‎typings/error.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
exporttypeErrorMessageView='FULL_PAGE'|'NOTIFY'|'NONE'
2+
3+
exporttypeErrorMessageType='UnknownError'|'GitNotFound'|'FailedToConnectToGitRepo'|'GitProjectAlreadyExists'
4+
5+
exporttypeErrorMessage={
6+
type:ErrorMessageType
7+
message:string
8+
display?:ErrorMessageView
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
###Failed to Connect to Git Repo
2+
3+
There are several possible causes:
4+
5+
- you may not be connected to the internet or have an unstable connection.
6+
- you may not have access permission to the remote tutorial repo.
7+
- the remote tutorial repo may not exist at the provided location

‎web-app/src/errors/GitNotFound.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
###Git Not Found
2+
3+
Make sure you install Git. See the[Git docs](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) for help.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
###Git Project Already Exists
2+
3+
CodeRoad requires an empty Git project.
4+
5+
Open a new workspace to start a tutorial.

‎web-app/src/errors/UnknownError.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
###Unknown Error
2+
3+
Sorry! An unknown error occurred.
4+
5+
Please help out by posting an issue at github.com/coderoad/coderoad-vscode/issues/new/choose!

‎web-app/tsconfig.paths.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"compilerOptions": {
33
"paths": {
44
"typings": ["../../typings/index.d.ts"],
5-
"typings/tutorial": ["../../typings/tutorial.d.ts"]
5+
"typings/tutorial": ["../../typings/tutorial.d.ts"],
6+
"typings/error": ["../../typings/error.d.ts"]
67
},
78
"allowSyntheticDefaultImports":true
89
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp