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

increased unknown error handling#263

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
ShMcK merged 1 commit intomasterfromerror-handling
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
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
317 changes: 175 additions & 142 deletionssrc/channel/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,49 +49,57 @@ class Channel implements Channel {

switch(actionType){
case'EDITOR_STARTUP':
// check if a workspace is open, otherwise nothing works
constnoActiveWorksapce=!WORKSPACE_ROOT.length
if(noActiveWorksapce){
consterror:E.ErrorMessage={
type:'NoWorkspaceFound',
message:'',
actions:[
{
label:'Open Workspace',
transition:'REQUEST_WORKSPACE',
},
],
try{
// check if a workspace is open, otherwise nothing works
constnoActiveWorksapce=!WORKSPACE_ROOT.length
if(noActiveWorksapce){
consterror:E.ErrorMessage={
type:'NoWorkspaceFound',
message:'',
actions:[
{
label:'Open Workspace',
transition:'REQUEST_WORKSPACE',
},
],
}
this.send({type:'NO_WORKSPACE',payload:{ error}})
return
}
this.send({type:'NO_WORKSPACE',payload:{ error}})
return
}

constenv={
machineId:vscode.env.machineId,
sessionId:vscode.env.sessionId,
}
constenv={
machineId:vscode.env.machineId,
sessionId:vscode.env.sessionId,
}

// continue from tutorial from local storage
consttutorial:TT.Tutorial|null=this.context.tutorial.get()
// continue from tutorial from local storage
consttutorial:TT.Tutorial|null=this.context.tutorial.get()

// new tutorial
if(!tutorial||!tutorial.id){
this.send({type:'START_NEW_TUTORIAL',payload:{ env}})
return
}
// new tutorial
if(!tutorial||!tutorial.id){
this.send({type:'START_NEW_TUTORIAL',payload:{ env}})
return
}

// set tutorial
const{ position, progress}=awaitthis.context.setTutorial(this.workspaceState,tutorial)
// set tutorial
const{ position, progress}=awaitthis.context.setTutorial(this.workspaceState,tutorial)

if(progress.complete){
// tutorial is already complete
this.send({type:'TUTORIAL_ALREADY_COMPLETE',payload:{ env}})
return
}
// communicate to client the tutorial & stepProgress state
this.send({type:'LOAD_STORED_TUTORIAL',payload:{ env, tutorial, progress, position}})

if(progress.complete){
// tutorial is already complete
this.send({type:'TUTORIAL_ALREADY_COMPLETE',payload:{ env}})
return
}catch(e){
consterror={
type:'UnknownError',
message:`Location: Editor startup\n\n${e.message}`,
}
this.send({type:'EDITOR_STARTUP_FAILED',payload:{ error}})
}
// communicate to client the tutorial & stepProgress state
this.send({type:'LOAD_STORED_TUTORIAL',payload:{ env, tutorial, progress, position}})

return

// clear tutorial local storage
case'TUTORIAL_CLEAR':
Expand All@@ -100,134 +108,159 @@ class Channel implements Channel {
return
// configure test runner, language, git
case'EDITOR_TUTORIAL_CONFIG':
constdata:TT.Tutorial=action.payload.tutorial
// setup tutorial config (save watcher, test runner, etc)
awaitthis.context.setTutorial(this.workspaceState,data)
try{
constdata:TT.Tutorial=action.payload.tutorial
// setup tutorial config (save watcher, test runner, etc)
awaitthis.context.setTutorial(this.workspaceState,data)

// validate dependencies
constdependencies=data.config.dependencies
if(dependencies&&dependencies.length){
for(constdepofdependencies){
// check dependency is installed
constcurrentVersion:string|null=awaitversion(dep.name)
if(!currentVersion){
// use a custom error message
consterror={
type:'MissingTutorialDependency',
message:dep.message||`Process "${dep.name}" is required but not found. It may need to be installed`,
actions:[
{
label:'Check Again',
transition:'TRY_AGAIN',
},
],
// validate dependencies
constdependencies=data.config.dependencies
if(dependencies&&dependencies.length){
for(constdepofdependencies){
// check dependency is installed
constcurrentVersion:string|null=awaitversion(dep.name)
if(!currentVersion){
// use a custom error message
consterror={
type:'MissingTutorialDependency',
message:
dep.message||`Process "${dep.name}" is required but not found. It may need to be installed`,
actions:[
{
label:'Check Again',
transition:'TRY_AGAIN',
},
],
}
this.send({type:'TUTORIAL_CONFIGURE_FAIL',payload:{ error}})
return
}
this.send({type:'TUTORIAL_CONFIGURE_FAIL',payload:{ error}})
return
}

// check dependency version
constsatisfiedDependency=awaitcompareVersions(currentVersion,dep.version)
// check dependency version
constsatisfiedDependency=awaitcompareVersions(currentVersion,dep.version)

if(!satisfiedDependency){
consterror={
type:'UnmetTutorialDependency',
message:`Expected${dep.name} to have version${dep.version}, but found version${currentVersion}`,
actions:[
{
label:'Check Again',
transition:'TRY_AGAIN',
},
],
if(!satisfiedDependency){
consterror={
type:'UnmetTutorialDependency',
message:`Expected${dep.name} to have version${dep.version}, but found version${currentVersion}`,
actions:[
{
label:'Check Again',
transition:'TRY_AGAIN',
},
],
}
this.send({type:'TUTORIAL_CONFIGURE_FAIL',payload:{ error}})
return
}
this.send({type:'TUTORIAL_CONFIGURE_FAIL',payload:{ error}})
return
}

if(satisfiedDependency!==true){
consterror=satisfiedDependency||{
type:'UnknownError',
message:`Something went wrong comparing dependency for${name}`,
actions:[
{
label:'Try Again',
transition:'TRY_AGAIN',
},
],
if(satisfiedDependency!==true){
consterror=satisfiedDependency||{
type:'UnknownError',
message:`Something went wrong comparing dependency for${name}`,
actions:[
{
label:'Try Again',
transition:'TRY_AGAIN',
},
],
}
this.send({type:'TUTORIAL_CONFIGURE_FAIL',payload:{ error}})
return
}
this.send({type:'TUTORIAL_CONFIGURE_FAIL',payload:{ error}})
return
}
}
}

consterror:E.ErrorMessage|void=awaittutorialConfig({config:data.config}).catch((error:Error)=>({
type:'UnknownError',
message:`Location: tutorial config.\n\n${error.message}`,
}))
consterror:E.ErrorMessage|void=awaittutorialConfig({config:data.config}).catch((error:Error)=>({
type:'UnknownError',
message:`Location: tutorial config.\n\n${error.message}`,
}))

// has error
if(error&&error.type){
this.send({type:'TUTORIAL_CONFIGURE_FAIL',payload:{ error}})
// has error
if(error&&error.type){
this.send({type:'TUTORIAL_CONFIGURE_FAIL',payload:{ error}})
return
}

// report back to the webview that setup is complete
this.send({type:'TUTORIAL_CONFIGURED'})
return
}catch(e){
consterror={
type:'UnknownError',
message:`Location: EditorTutorialConfig.\n\n${e.message}`,
}
this.send({type:'TUTORIAL_CONFIGURE_FAIL',payload:{ error}})
}

// report back to the webview that setup is complete
this.send({type:'TUTORIAL_CONFIGURED'})
return
case'EDITOR_TUTORIAL_CONTINUE_CONFIG':
consttutorialContinue:TT.Tutorial|null=this.context.tutorial.get()
if(!tutorialContinue){
thrownewError('Invalid tutorial to continue')
try{
consttutorialContinue:TT.Tutorial|null=this.context.tutorial.get()
if(!tutorialContinue){
thrownewError('Invalid tutorial to continue')
}
constcontinueConfig:TT.TutorialConfig=tutorialContinue.config
awaittutorialConfig({
config:continueConfig,
alreadyConfigured:true,
})
// update the current stepId on startup
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP,action.payload)
return
}catch(e){
consterror={
type:'UnknownError',
message:`Location: Editor tutorial continue config.\n\n${e.message}`,
}
this.send({type:'CONTINUE_FAILED',payload:{ error}})
}
constcontinueConfig:TT.TutorialConfig=tutorialContinue.config
awaittutorialConfig({
config:continueConfig,
alreadyConfigured:true,
})
// update the current stepId on startup
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_STEP,action.payload)
return
case'EDITOR_VALIDATE_SETUP':
// check workspace is selected
constisEmptyWorkspace=awaitcheckWorkspaceEmpty()
if(!isEmptyWorkspace){
consterror:E.ErrorMessage={
type:'WorkspaceNotEmpty',
message:'',
actions:[
{
label:'Open Workspace',
transition:'REQUEST_WORKSPACE',
},
{
label:'Check Again',
transition:'RETRY',
},
],
try{
// check workspace is selected
constisEmptyWorkspace=awaitcheckWorkspaceEmpty()
if(!isEmptyWorkspace){
consterror:E.ErrorMessage={
type:'WorkspaceNotEmpty',
message:'',
actions:[
{
label:'Open Workspace',
transition:'REQUEST_WORKSPACE',
},
{
label:'Check Again',
transition:'RETRY',
},
],
}
this.send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})
return
}
this.send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})
// check Git is installed.
// Should wait for workspace before running otherwise requires access to root folder
constisGitInstalled=awaitversion('git')
if(!isGitInstalled){
consterror:E.ErrorMessage={
type:'GitNotFound',
message:'',
actions:[
{
label:'Check Again',
transition:'RETRY',
},
],
}
this.send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})
return
}
this.send({type:'SETUP_VALIDATED'})
return
}
// check Git is installed.
// Should wait for workspace before running otherwise requires access to root folder
constisGitInstalled=awaitversion('git')
if(!isGitInstalled){
consterror:E.ErrorMessage={
type:'GitNotFound',
message:'',
actions:[
{
label:'Check Again',
transition:'RETRY',
},
],
}catch(e){
consterror={
type:'UknownError',
message:e.message,
}
this.send({type:'VALIDATE_SETUP_FAILED',payload:{ error}})
return
}
this.send({type:'SETUP_VALIDATED'})
return
case'EDITOR_REQUEST_WORKSPACE':
openWorkspace()
return
Expand Down
7 changes: 7 additions & 0 deletionsweb-app/src/services/state/machine.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,6 +37,9 @@ export const createMachine = (options: any) => {
onEntry: ['startup'],
onExit: ['clearError'],
on: {
EDITOR_STARTUP_FAILED: {
actions: ['setError'],
},
NO_WORKSPACE: {
actions: ['setError'],
},
Expand DownExpand Up@@ -74,12 +77,16 @@ export const createMachine = (options: any) => {
},
},
Start: {
onExit: ['clearError'],
on: {
NEW_TUTORIAL: 'ValidateSetup',
CONTINUE_TUTORIAL: {
target: '#tutorial-level',
actions: ['continueConfig'],
},
CONTINUE_FAILED: {
actions: ['setError'],
},
},
},
SelectTutorial: {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp