Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task/WG-295: improve error message when duplicate syncing project #255

Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
}
);
Expand Down
13 changes: 4 additions & 9 deletions angular/src/app/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,10 @@ export class ProjectsService {

create(data: ProjectRequest): Observable<Project> {
return this.http.post<Project>(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]);
})
);
}

Expand Down
Loading