Skip to content
Snippets Groups Projects
Commit fc690171 authored by michael.minelli's avatar michael.minelli
Browse files

HttpManager => Display general error only when there is no custom one

parent bc700eb0
Branches
Tags
No related merge requests found
Pipeline #30870 passed
......@@ -36,15 +36,21 @@ class DojoBackendManager {
case DojoStatusCode.ASSIGNMENT_NAME_CONFLICT:
spinner.fail(`Assignment creation error: The assignment name already exists. Please choose another name.`);
break;
case DojoStatusCode.ASSIGNMENT_CREATION_ERROR:
case DojoStatusCode.ASSIGNMENT_CREATION_GITLAB_ERROR:
spinner.fail(`Assignment creation error: An unknown error occurred while creating the assignment on GitLab (internal error message: ${ error.response?.data?.description ?? 'unknown error' }). Please try again later or contact an administrator.`);
break;
case DojoStatusCode.ASSIGNMENT_CREATION_INTERNAL_ERROR:
spinner.fail(`Assignment creation error: An unknown error occurred while creating the assignment (internal error message: ${ error.response?.data?.description ?? 'unknown error' }). Please try again later or contact an administrator.`);
break;
case 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<Gitlab.UserSchema>>).data).map(user => user.name).join(', ') }.`);
break;
case DojoStatusCode.EXERCISE_CREATION_ERROR:
case DojoStatusCode.EXERCISE_CREATION_INTERNAL_ERROR:
spinner.fail(`Exercise creation error: An unknown error occurred while creating the exercise (internal error message: ${ error.response?.data?.description ?? 'unknown error' }). Please try again later or contact an administrator.`);
break;
case DojoStatusCode.EXERCISE_CREATION_GITLAB_ERROR:
spinner.fail(`Exercise creation error: An unknown error occurred while creating the exercise on GitLab (internal error message: ${ error.response?.data?.description ?? 'unknown error' }). Please try again later or contact an administrator.`);
break;
case DojoStatusCode.GITLAB_TEMPLATE_NOT_FOUND:
spinner.fail(`Template not found or access denied. Please check the template ID or url. Also, please check that the template have public/internal visibility or that your and Dojo account (${ ClientsSharedConfig.gitlab.dojoAccount.username }) have at least reporter role to the template (if private).`);
break;
......
......@@ -76,16 +76,20 @@ class HttpManager {
private apiAuthorizationError(error: AxiosError, isFromApi: boolean) {
if ( this.handleAuthorizationCommandErrors && isFromApi && error.response ) {
switch ( error.response.status ) {
case StatusCodes.UNAUTHORIZED:
this.requestError('Session expired or does not exist. Please login again.');
break;
case StatusCodes.FORBIDDEN:
this.requestError('Forbidden access.');
break;
default:
this.requestError('Unknown error.');
break;
const errorCustomCode = (error.response.data as DojoBackendResponse<unknown> | undefined)?.code ?? error.response.status;
if ( errorCustomCode === error.response.status ) {
switch ( error.response.status ) {
case StatusCodes.UNAUTHORIZED:
this.requestError('Session expired or does not exist. Please login again.');
break;
case StatusCodes.FORBIDDEN:
this.requestError('Forbidden access.');
break;
default:
this.requestError('Unknown error.');
break;
}
}
} else {
this.handleAuthorizationCommandErrors = true;
......
Subproject commit 47b289f99ef88df993f5977efa6a53e4bd0abe85
Subproject commit 556a235605ba36ea775cd54da4aee8a5bc03d912
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment