diff --git a/angular/src/app/components/modal-create-project/modal-create-project.component.ts b/angular/src/app/components/modal-create-project/modal-create-project.component.ts index a0aa7885..c0f30a1a 100644 --- a/angular/src/app/components/modal-create-project/modal-create-project.component.ts +++ b/angular/src/app/components/modal-create-project/modal-create-project.component.ts @@ -1,4 +1,5 @@ import { Component, OnInit, AfterContentChecked } from '@angular/core'; +import { HttpErrorResponse } from '@angular/common/http'; import { BsModalRef } from 'ngx-foundation'; import { FormGroup, FormControl } from '@angular/forms'; import { ProjectsService } from '../../services/projects.service'; @@ -87,9 +88,13 @@ export class ModalCreateProjectComponent implements OnInit, AfterContentChecked (project) => { this.close(project); }, - (err) => { - this.errorMessage = err.error && err.error.message ? err.error.message : 'That folder is already syncing with a different map!'; - + (err: HttpErrorResponse) => { + if (err.status === 409) { + this.errorMessage = 'That folder is already syncing with a different map!'; + } else { + this.errorMessage = + err.error && err.error.message ? err.error.message : 'An error occurred while creating the project. Please contact support.'; + } this.submitting = false; } ); diff --git a/angular/src/app/services/projects.service.ts b/angular/src/app/services/projects.service.ts index bb73ef18..019736db 100644 --- a/angular/src/app/services/projects.service.ts +++ b/angular/src/app/services/projects.service.ts @@ -112,15 +112,10 @@ export class ProjectsService { create(data: ProjectRequest): Observable { return this.http.post(this.envService.apiUrl + `/projects/`, data).pipe( - tap( - (proj) => { - // Spread operator, just pushes the new project into the array - this._projects.next([...this._projects.value, proj]); - }, - (error) => { - console.log(error); - } - ) + tap((proj) => { + // Spread operator, just pushes the new project into the array + this._projects.next([...this._projects.value, proj]); + }) ); }