-
![]()
+
diff --git a/src/app/components/show-details/show-details.component.ts b/src/app/components/show-details/show-details.component.ts
index 3201695..5bc5192 100644
--- a/src/app/components/show-details/show-details.component.ts
+++ b/src/app/components/show-details/show-details.component.ts
@@ -1,14 +1,13 @@
import {Component, Input} from '@angular/core';
import {BehaviorSubject} from 'rxjs';
import {Show} from '../../model/show';
-import {AsyncPipe, NgOptimizedImage} from '@angular/common';
+import {AsyncPipe} from '@angular/common';
@Component({
selector: 'app-show-details',
standalone: true,
imports: [
- AsyncPipe,
- NgOptimizedImage
+ AsyncPipe
],
templateUrl: './show-details.component.html',
styleUrl: './show-details.component.css'
diff --git a/src/app/services/api-service.ts b/src/app/services/api-service.ts
index 7e4efb6..b71e37c 100644
--- a/src/app/services/api-service.ts
+++ b/src/app/services/api-service.ts
@@ -1,7 +1,7 @@
import {inject, Injectable} from '@angular/core';
import {Show} from '../model/show';
import {HttpClient} from '@angular/common/http';
-import {map, Observable} from 'rxjs';
+import {catchError, map, Observable, throwError} from 'rxjs';
import {ShowDTO} from '../model/ShowDto';
@Injectable({
@@ -15,10 +15,20 @@ export class ApiService {
const apiUrl = `${this.baseUrl}/singlesearch/shows?q=${title}`;
let show: Show = new Show(0, title);
- return this.httpClient.get
(apiUrl).pipe(map((s) => {
- show.summary = s.summary;
- show.image = s.image?.medium;
- return show;
- }));
+ return this.httpClient.get(apiUrl).pipe(
+ catchError(err => {
+ let errorMessage;
+ if (err.status == 404) {
+ errorMessage = "Eine Serie mit diesem Titel konnte nicht gefunden werden.";
+ } else {
+ errorMessage = err.message();
+ }
+ return throwError(() => console.log(errorMessage));
+ }),
+ map((s) => {
+ show.summary = s.summary;
+ show.image = s.image?.medium;
+ return show;
+ }));
}
}