Merge remote-tracking branch 'origin/master'

master
Max 4 years ago
commit e7711d7b4f

@ -43,7 +43,7 @@ const routes: Routes = [
{ path: 'table/equipmentTypes', component: EquipmentTypesComponent, canActivate: [AuthGuard] }, { path: 'table/equipmentTypes', component: EquipmentTypesComponent, canActivate: [AuthGuard] },
{ path: 'table/engagementTypes', component: EngagementTypesComponent, canActivate: [AuthGuard] }, { path: 'table/engagementTypes', component: EngagementTypesComponent, canActivate: [AuthGuard] },
{ path: 'table/engagements', component: EngagementsComponent, canActivate: [AuthGuard] }, { path: 'table/engagements', component: EngagementsComponent, canActivate: [AuthGuard] },
{ path: 'table/equipments', component: EquipmentComponent, canActivate: [AuthGuard] }, { path: 'table/equipment', component: EquipmentComponent, canActivate: [AuthGuard] },
{ path: 'table/timeFrames', component: TimeFramesComponent, canActivate: [AuthGuard] }, { path: 'table/timeFrames', component: TimeFramesComponent, canActivate: [AuthGuard] },
{ path: 'table/persons', component: PersonsComponent, canActivate: [AuthGuard] }, { path: 'table/persons', component: PersonsComponent, canActivate: [AuthGuard] },
{ path: 'table/contactInformation', component: ContactInformationComponent, canActivate: [AuthGuard] }, { path: 'table/contactInformation', component: ContactInformationComponent, canActivate: [AuthGuard] },

@ -28,11 +28,12 @@ export class TokenInterceptor implements HttpInterceptor {
let errorMessage = ''; let errorMessage = '';
if (error.error instanceof ErrorEvent) { if (error.error instanceof ErrorEvent) {
//client error //client error
//console.log("Client Error: " + JSON.stringify(error));
errorMessage = `Error: ${error.error.message}`; errorMessage = `Error: ${error.error.message}`;
} else { } else {
//server error //server error
//console.log("Error: " + JSON.stringify(error)); //console.log("Server Error: " + JSON.stringify(error));
if (error.status === 400){ if (error.status === 400){
switch (error.error.message) { switch (error.error.message) {
case "Invalid refresh token!": case "Invalid refresh token!":
@ -57,7 +58,7 @@ export class TokenInterceptor implements HttpInterceptor {
errorMessage = this.serverErrorMessageGenerator(error); errorMessage = this.serverErrorMessageGenerator(error);
} }
} }
if (errorMessage === "Viele Fehler sind aufgetreten.") { if (errorMessage === "Viele Fehler sind aufgetreten.") { // Here is the thing I ment
this.snackBar.openSnackBar(errorMessage, "Erweitert", true, error.error.errors); this.snackBar.openSnackBar(errorMessage, "Erweitert", true, error.error.errors);
} else { } else {
this.snackBar.openSnackBar(errorMessage, "Ok", true); this.snackBar.openSnackBar(errorMessage, "Ok", true);
@ -68,13 +69,14 @@ export class TokenInterceptor implements HttpInterceptor {
} }
private serverErrorMessageGenerator (error: HttpErrorResponse): string { private serverErrorMessageGenerator (error: HttpErrorResponse): string {
if (error.error?.errors[0]?.message?.includes("not provided")) {
return "Nicht alle benötigten Felder wurden ausgefüllt.";
}
if (error.error.message === undefined){ if (error.error.message === undefined){
return "Viele Fehler sind aufgetreten." // If you change this you have to change it over this aswell if (error.error.errors[0].message.includes("not provided")) {
return "Nicht alle benötigten Felder wurden ausgefüllt.";
} else {
return "Viele Fehler sind aufgetreten." // If you change this you have to change it over this aswell ( I know its terrible to @ )
}
} else { } else {
`${error.error.message}. Fehlercode: ${error.status}.`; return `${error.error.message}.`; //`${error.error.message}. Fehlercode: ${error.status}.`
} }
} }

Loading…
Cancel
Save