import { inject, Injectable } from '@angular/core';
import { Router } from "@angular/router";
-import { Observable, of } from 'rxjs';
+import { Observable, of, throwError } from 'rxjs';
@Injectable({
providedIn: 'root'
private username : string|undefined;
login(username : string, password : string) : Observable<string> {
+ const shouldFail = Math.random() < 0.3; // 30% Fehlerchance
+ if (shouldFail) {
+ return throwError(() => new Error('Simulierter Fehler im Service'));
+ }
+ this.username = username;
return of(username);
}