From 5108073c673077869b832a74687f110731eb4a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <michael@minelli.me> Date: Tue, 23 Jan 2024 17:34:09 +0100 Subject: [PATCH] ExerciseCreate => Manage the MAX_EXERCISE_PER_ASSIGNMENT_REACHED error --- NodeApp/src/managers/DojoBackendManager.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/NodeApp/src/managers/DojoBackendManager.ts b/NodeApp/src/managers/DojoBackendManager.ts index d371100..b8e8a41 100644 --- a/NodeApp/src/managers/DojoBackendManager.ts +++ b/NodeApp/src/managers/DojoBackendManager.ts @@ -142,8 +142,12 @@ class DojoBackendManager { if ( verbose ) { if ( error instanceof AxiosError ) { if ( error.response ) { - if ( error.response.status === StatusCodes.CONFLICT ) { - spinner.fail(`You've already reached the max number of exercise of this assignment.`); + if ( error.response.status === StatusCodes.INSUFFICIENT_SPACE_ON_RESOURCE ) { + if ( error.response.data && (error.response.data as DojoBackendResponse<Array<GitlabUser>>).code === DojoStatusCode.MAX_EXERCISE_PER_ASSIGNMENT_REACHED ) { + spinner.fail(`The following users have reached the maximum number of exercise of this assignment : ${ ((error.response.data as DojoBackendResponse<Array<GitlabUser>>).data as Array<GitlabUser>).map(user => user.name).join(', ') }.`); + } else { + spinner.fail(`You've already reached the max number of exercise of this assignment.`); + } } else { if ( (error.response.data as DojoBackendResponse<unknown>).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.`); -- GitLab