TSK-931: Basic structure for global error handling

This commit is contained in:
Finn Mißfeldt 2019-11-19 13:04:01 +01:00
parent 9405cdfed6
commit de72ee647b
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';
import { ErrorsService } from './errors.service';
describe('ErrorsService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: ErrorsService = TestBed.get(ErrorsService);
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,22 @@
import { ErrorHandler, Injectable } from '@angular/core';
import { Subject } from 'rxjs';
import { ErrorModel } from '../../../models/error-model';
import { ERROR_TYPES } from '../../../services/general-modal/errors';
@Injectable({
providedIn: 'root'
})
export class ErrorsService {
// Wie initialisieren? Default ERROR_TYPE für leeres initialisieren einfügen?
errorSubject$: Subject<ErrorModel>;
constructor() {}
private updateErrorSubject(errorToShow: ErrorModel) {
this.errorSubject$.next(errorToShow);
}
public updateError(key: ERROR_TYPES, passedError: ErrorHandler): void {
// wahrscheinlich wollen wir nicht jedes mal ein neues ErrorModel erzeugen... oder wollen wir?
this.updateErrorSubject(new ErrorModel(key, passedError));
}
}