fixed interceptor and equipment

master
FlayInAHook 4 years ago
parent 61bd7cc266
commit a21d1ab4e9

@ -43,7 +43,7 @@ const routes: Routes = [
{ path: 'table/equipmentTypes', component: EquipmentTypesComponent, canActivate: [AuthGuard] },
{ path: 'table/engagementTypes', component: EngagementTypesComponent, 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/persons', component: PersonsComponent, canActivate: [AuthGuard] },
{ path: 'table/contactInformation', component: ContactInformationComponent, canActivate: [AuthGuard] },

@ -28,11 +28,12 @@ export class TokenInterceptor implements HttpInterceptor {
let errorMessage = '';
if (error.error instanceof ErrorEvent) {
//client error
//console.log("Client Error: " + JSON.stringify(error));
errorMessage = `Error: ${error.error.message}`;
} else {
//server error
//console.log("Error: " + JSON.stringify(error));
//console.log("Server Error: " + JSON.stringify(error));
if (error.status === 400){
switch (error.error.message) {
case "Invalid refresh token!":
@ -57,7 +58,7 @@ export class TokenInterceptor implements HttpInterceptor {
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);
} else {
this.snackBar.openSnackBar(errorMessage, "Ok", true);
@ -68,13 +69,14 @@ export class TokenInterceptor implements HttpInterceptor {
}
private serverErrorMessageGenerator (error: HttpErrorResponse): string {
if (error.error?.errors[0]?.message?.includes("not provided")) {
if (error.error.message === undefined){
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 @ )
}
if (error.error.message === undefined){
return "Viele Fehler sind aufgetreten." // If you change this you have to change it over this aswell
} else {
`${error.error.message}. Fehlercode: ${error.status}.`;
return `${error.error.message}.`; //`${error.error.message}. Fehlercode: ${error.status}.`
}
}

Loading…
Cancel
Save