Skip to content

Commit eb07097

Browse files
committed
fix(client-profile): handle missing profile image and remove skipErrorHandler usage
- Use standard HTTP error handling instead of skipErrorHandler - Handle 404 errors gracefully in component as expected behavior
1 parent f1adfaf commit eb07097

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/app/clients/clients-view/clients-view.component.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,21 @@ export class ClientsViewComponent implements OnInit {
9090
}
9191

9292
ngOnInit() {
93-
this.clientsService.getClientProfileImage(this.clientViewData.id).subscribe(
94-
(base64Image: any) => {
93+
this.clientsService.getClientProfileImage(this.clientViewData.id).subscribe({
94+
next: (base64Image: any) => {
9595
this.clientImage = this._sanitizer.bypassSecurityTrustResourceUrl(base64Image);
9696
},
97-
(error: any) => {}
98-
);
97+
error: (error: any) => {
98+
// 404 is expected when client has no profile image - not an error
99+
if (error.status === 404) {
100+
this.clientImage = null;
101+
} else {
102+
// Log other unexpected errors
103+
console.error('Error loading client profile image:', error);
104+
this.clientImage = null;
105+
}
106+
}
107+
});
99108
}
100109

101110
isActive(): boolean {

src/app/clients/clients.service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { HttpClient, HttpParams } from '@angular/common/http';
44

55
/** rxjs Imports */
66
import { Observable } from 'rxjs';
7+
78
/**
89
* Clients service.
910
*/
@@ -170,9 +171,7 @@ export class ClientsService {
170171

171172
getClientProfileImage(clientId: string) {
172173
const httpParams = new HttpParams().set('maxHeight', '150');
173-
return this.http
174-
.skipErrorHandler()
175-
.get(`/clients/${clientId}/images`, { params: httpParams, responseType: 'text' });
174+
return this.http.get(`/clients/${clientId}/images`, { params: httpParams, responseType: 'text' });
176175
}
177176

178177
uploadClientProfileImage(clientId: string, image: File) {

0 commit comments

Comments
 (0)