From db854edcccec2ca87d9feedfd3f2c76d483b0da6 Mon Sep 17 00:00:00 2001 From: mechtelm <nicht@mehr.fragen> Date: Mon, 27 Apr 2020 18:26:14 +0200 Subject: [PATCH] xml upload error reported properly again #128 --- src/app/app-root/login/login.component.html | 1 + .../iqbFilesUpload.component.ts | 23 +++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/app/app-root/login/login.component.html b/src/app/app-root/login/login.component.html index 8b55f4d8..1320054b 100644 --- a/src/app/app-root/login/login.component.html +++ b/src/app/app-root/login/login.component.html @@ -14,6 +14,7 @@ <button mat-raised-button type="submit" [disabled]="loginForm.invalid" color="primary">Weiter</button> </mat-card-actions> </form> + <p style="color: chocolate"><b>{{ problemText }}</b></p> <p style="color: chocolate" *ngIf="!mds.isApiValid"><b>Die Verbindung mit dem Server ist nicht möglich.</b></p> </mat-card> diff --git a/src/app/workspace-admin/files/iqb-files/iqbFilesUpload/iqbFilesUpload.component.ts b/src/app/workspace-admin/files/iqb-files/iqbFilesUpload/iqbFilesUpload.component.ts index 8cf0436f..03efc74d 100644 --- a/src/app/workspace-admin/files/iqb-files/iqbFilesUpload/iqbFilesUpload.component.ts +++ b/src/app/workspace-admin/files/iqb-files/iqbFilesUpload/iqbFilesUpload.component.ts @@ -1,6 +1,9 @@ import {Component, EventEmitter, Input, OnInit, Output, HostBinding, OnDestroy} from '@angular/core'; -import { HttpClient, HttpEventType, HttpHeaders, HttpParams, - HttpEvent } from '@angular/common/http'; +import { + HttpClient, HttpEventType, HttpHeaders, HttpParams, + HttpEvent, HttpErrorResponse +} from '@angular/common/http'; +import {ApiError} from "../../../../app.interfaces"; @Component({ @@ -153,12 +156,24 @@ import { HttpClient, HttpEventType, HttpHeaders, HttpParams, this.remove(); } } - }, () => { + }, (err) => { if (this.fileUploadSubscription) { this.fileUploadSubscription.unsubscribe(); } - this.status = UploadStatus.error; + if (err instanceof HttpErrorResponse) { + this.requestResponseText = (err as HttpErrorResponse).message; + } else if (err instanceof ApiError) { + const apiError: ApiError = err; + if (apiError.code === 422) { + const slashPos = apiError.info.indexOf(' // '); + this.requestResponseText = (slashPos > 0) ? apiError.info.substr(slashPos + 4) : apiError.info; + } else { + this.requestResponseText = apiError.info; + } + } else { + this.requestResponseText = 'Hochladen nicht erfolgreich.' + } }); } } -- GitLab