diff --git a/NodeApp/src/commander/assignment/subcommands/AssignmentCreateCommand.ts b/NodeApp/src/commander/assignment/subcommands/AssignmentCreateCommand.ts index 0b28a1c7ff9302c5b0416043e8bc3421cbbfb96b..7a5bea4403c7e963a948ccc04c945ee17e35fa4d 100644 --- a/NodeApp/src/commander/assignment/subcommands/AssignmentCreateCommand.ts +++ b/NodeApp/src/commander/assignment/subcommands/AssignmentCreateCommand.ts @@ -61,14 +61,15 @@ class AssignmentCreateCommand extends CommanderCommand { // Create the assignment { - console.log(chalk.cyan('Please wait while we are creating the assignment...')); + console.log(chalk.cyan('Please wait while we are creating the assignment (approximately 10 seconds)...')); try { const assignment: Assignment = await DojoBackendManager.createAssignment(options.name, members, templateIdOrNamespace); const oraInfo = (message: string) => { ora({ - text: message, indent: 4 + text : message, + indent: 4 }).start().info(); }; diff --git a/NodeApp/src/commander/exercise/subcommands/ExerciseCreateCommand.ts b/NodeApp/src/commander/exercise/subcommands/ExerciseCreateCommand.ts index bb51c2e6ece83361bd4fa5bd011b8d2e5731f97b..5b547df82b9c26433806d861a5ae5f7da581a8c7 100644 --- a/NodeApp/src/commander/exercise/subcommands/ExerciseCreateCommand.ts +++ b/NodeApp/src/commander/exercise/subcommands/ExerciseCreateCommand.ts @@ -40,7 +40,8 @@ class ExerciseCreateCommand extends CommanderCommand { ora('Checking assignment:').start().info(); const assignmentGetSpinner: ora.Ora = ora({ - text: 'Checking if assignment exists', indent: 4 + text : 'Checking if assignment exists', + indent: 4 }).start(); assignment = await DojoBackendManager.getAssignment(options.assignment); if ( !assignment ) { @@ -50,7 +51,8 @@ class ExerciseCreateCommand extends CommanderCommand { assignmentGetSpinner.succeed(`Assignment "${ options.assignment }" exists`); const assignmentPublishedSpinner: ora.Ora = ora({ - text: 'Checking if assignment is published', indent: 4 + text : 'Checking if assignment is published', + indent: 4 }).start(); if ( !assignment.published ) { assignmentPublishedSpinner.fail(`Assignment "${ assignment.name }" isn't published`); @@ -61,14 +63,15 @@ class ExerciseCreateCommand extends CommanderCommand { //Create the exercise { - console.log(chalk.cyan('Please wait while we are creating the exercise...')); + console.log(chalk.cyan('Please wait while we are creating the exercise (approximately 10 seconds)...')); try { const exercise: Exercise = await DojoBackendManager.createExercise((assignment as Assignment).name, members); const oraInfo = (message: string) => { ora({ - text: message, indent: 4 + text : message, + indent: 4 }).start().info(); }; diff --git a/NodeApp/src/managers/DojoBackendManager.ts b/NodeApp/src/managers/DojoBackendManager.ts index 12cc16b6822a4414fe2f01408cf58f3627624b19..42bda3fa67ec31b4f9be6bba3e5da406c8f8224e 100644 --- a/NodeApp/src/managers/DojoBackendManager.ts +++ b/NodeApp/src/managers/DojoBackendManager.ts @@ -9,6 +9,7 @@ import DojoBackendResponse from '../shared/types/Dojo/DojoBackendResponse'; import Exercise from '../sharedByClients/models/Exercise'; import GitlabToken from '../shared/types/Gitlab/GitlabToken'; import User from '../sharedByClients/models/User'; +import DojoStatusCode from '../shared/types/Dojo/DojoStatusCode'; class DojoBackendManager { @@ -106,7 +107,11 @@ class DojoBackendManager { if ( error.response.status === StatusCodes.CONFLICT ) { spinner.fail(`The assignment name is already used. Please choose another one.`); } else { - spinner.fail(`Assignment creation error: ${ error.response.statusText }`); + if ( (error.response.data as DojoBackendResponse<any>).code === DojoStatusCode.ASSIGNMENT_CREATION_GITLAB_ERROR ) { + spinner.fail(`Assignment creation error: An unknown error occurred while creating the assignment on Gitlab. Please try again later or contact an administrator.`); + } else { + spinner.fail(`Assignment creation error: An unknown error occurred while creating the assignment on Dojo server. Please try again later or contact an administrator.`); + } } } } else { @@ -140,7 +145,11 @@ class DojoBackendManager { if ( error.response.status === StatusCodes.CONFLICT ) { spinner.fail(`You've already reached the max number of exercise of this assignment.`); } else { - spinner.fail(`Exercise creation error: ${ error.response.statusText }`); + if ( (error.response.data as DojoBackendResponse<any>).code === DojoStatusCode.EXERCISE_CREATION_GITLAB_ERROR ) { + spinner.fail(`Exercise creation error: An unknown error occurred while creating the exercise on Gitlab. Please try again later or contact an administrator.`); + } else { + spinner.fail(`Exercise creation error: An unknown error occurred while creating the exercise on Dojo server. Please try again later or contact an administrator.`); + } } } } else { diff --git a/NodeApp/src/shared b/NodeApp/src/shared index 6607858180da1c27f87f5f078e45091d45fe8caf..4a5eb68209ae9204b6d4cc8020bd62cf6a5be989 160000 --- a/NodeApp/src/shared +++ b/NodeApp/src/shared @@ -1 +1 @@ -Subproject commit 6607858180da1c27f87f5f078e45091d45fe8caf +Subproject commit 4a5eb68209ae9204b6d4cc8020bd62cf6a5be989