Commit 8f07efc4 authored by Lukas Burgey's avatar Lukas Burgey

Make http error handling consistent

Closes #5
parent a1a5727d
......@@ -218,13 +218,7 @@ export class UserService {
if (fetch) {
this.fetch();
}
}
}
private catchError(fetch: boolean, msg?: string) {
return (error: any) => {
this.handleError(fetch, msg)(error);
return EMPTY;
return EMPTY
}
}
......@@ -258,14 +252,18 @@ export class UserService {
}
public sentQuestionnaire(stateItemID: number, answers: Object) {
return this.http.post<Deployment>('/backend/api/questionnaire?id='+String(stateItemID), answers).subscribe(
return this.http.post<Deployment>('/backend/api/questionnaire?id='+String(stateItemID), answers).pipe(
catchError(this.handleError(true, "Error submitting questionnaire")),
).subscribe(
(dep: Deployment) => this.updateDeployment(dep),
this.logErrorAndFetch,
);
}
public deleteUser() {
return this.http.delete('/backend/api/delete_user').subscribe(
return this.http.delete('/backend/api/delete_user').pipe(
catchError(this.handleError(true, "Error deleting user")),
).subscribe(
(data: {deleted: boolean}) => {
if (data && data.deleted) {
this.user$.next(undefined);
......@@ -277,7 +275,9 @@ export class UserService {
}
public uploadSshKey(formData: FormData): void {
this.http.post<SSHKey>('/backend/api/sshkey', formData).subscribe(
this.http.post<SSHKey>('/backend/api/sshkey', formData).pipe(
catchError(this.handleError(true, "Error changing deployment")),
).subscribe(
(newKey: SSHKey) => {
this.sshKeys.push(newKey);
this.sshKeys$.next(this.sshKeys);
......@@ -291,7 +291,9 @@ export class UserService {
return this.http.post('/backend/api/sshkey', {
'type': 'remove',
'id': key.id,
}).subscribe(
}).pipe(
catchError(this.handleError(true, "Error changing deployment")),
).subscribe(
(data: {deleted: boolean}) => {
if (data && data.deleted) {
this.sshKeys = this.sshKeys.filter(
......@@ -310,7 +312,7 @@ export class UserService {
'vo': vo.id,
};
this.http.post<Deployment>('/backend/api/deployments', body).pipe(
catchError(this.catchError(true, "Error changing deployment")),
catchError(this.handleError(true, "Error changing deployment")),
).subscribe(
(dep: Deployment) => this.updateDeployment(dep),
);
......@@ -322,7 +324,7 @@ export class UserService {
'service': service.id,
};
this.http.post<Deployment>('/backend/api/deployments', body).pipe(
catchError(this.catchError(true, "Error changing deployment")),
catchError(this.handleError(true, "Error changing deployment")),
).subscribe(
(dep: Deployment) => this.updateDeployment(dep),
);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment