TSK-931: Basic structure for global error handling
This commit is contained in:
parent
9405cdfed6
commit
de72ee647b
|
@ -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();
|
||||
});
|
||||
});
|
|
@ -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));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue