Basic structure for global error handling
This commit is contained in:
parent
8b3c6b34c9
commit
9405cdfed6
|
@ -35,6 +35,8 @@ import { NoAccessComponent } from 'app/components/no-access/no-access.component'
|
|||
import { RemoveConfirmationService } from './services/remove-confirmation/remove-confirmation.service';
|
||||
import { FormsValidatorService } from './shared/services/forms/forms-validator.service';
|
||||
import { UploadService } from './shared/services/upload/upload.service';
|
||||
import { ErrorsService } from './shared/services/errors/errors.service';
|
||||
|
||||
|
||||
/**
|
||||
* Components
|
||||
|
@ -107,6 +109,7 @@ export function startupServiceFactory(startupService: StartupService): () => Pro
|
|||
RemoveConfirmationService,
|
||||
FormsValidatorService,
|
||||
UploadService,
|
||||
ErrorsService,
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import { ErrorHandler } from '@angular/core';
|
||||
import { ERROR_TYPES, errors } from '../services/general-modal/errors';
|
||||
|
||||
export class ErrorModel {
|
||||
head: string;
|
||||
body: string;
|
||||
errObj?: ErrorHandler;
|
||||
|
||||
constructor(key: ERROR_TYPES, passedError?: ErrorHandler) {
|
||||
this.head = errors.get(key).name;
|
||||
this.body = errors.get(key).text;
|
||||
this.errObj = passedError;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
import { ErrorModel } from '../../models/error-model';
|
||||
import {Pair} from '../../models/pair';
|
||||
|
||||
|
||||
export enum ERROR_TYPES {
|
||||
NO_AUTH,
|
||||
EXP_AUTH,
|
||||
NO_ACCESS,
|
||||
}
|
||||
// TODO: funktioniert unser Pair hierfür? -> Konstruktor checken!
|
||||
export const errors = new Map<ERROR_TYPES, Pair> ([
|
||||
[ERROR_TYPES.NO_AUTH, new Pair(
|
||||
'Authentication required',
|
||||
'You need to be logged in to perform this action.'
|
||||
)],
|
||||
[ERROR_TYPES.EXP_AUTH, new Pair(
|
||||
'Authentication expired',
|
||||
'Your session has expired, log in to perform this action.'
|
||||
)],
|
||||
[ERROR_TYPES.NO_ACCESS, new Pair(
|
||||
'Access denied',
|
||||
'You have no permission to perform this action.'
|
||||
)],
|
||||
]);
|
|
@ -2,6 +2,8 @@ import { Injectable } from '@angular/core';
|
|||
import { Subject, Observable } from 'rxjs';
|
||||
import { MessageModal } from 'app/models/message-modal';
|
||||
|
||||
import { errors as ERRORS } from './errors';
|
||||
|
||||
@Injectable()
|
||||
export class GeneralModalService {
|
||||
private messageTriggered = new Subject<MessageModal>();
|
||||
|
|
Loading…
Reference in New Issue