ciyidogan commited on
Commit
98f89fc
·
verified ·
1 Parent(s): 66d5a73

Update flare-ui/src/app/services/api.service.ts

Browse files
flare-ui/src/app/services/api.service.ts CHANGED
@@ -290,6 +290,7 @@ export class ApiService {
290
  );
291
  }
292
 
 
293
  // ===================== Error Handler =====================
294
  private handleError(error: any) {
295
  console.error('API Error:', error);
@@ -297,6 +298,16 @@ export class ApiService {
297
  if (error.status === 401) {
298
  // Token expired or invalid
299
  this.authService.logout();
 
 
 
 
 
 
 
 
 
 
300
  }
301
 
302
  return throwError(() => error.error || error);
 
290
  );
291
  }
292
 
293
+ // ===================== Error Handler =====================
294
  // ===================== Error Handler =====================
295
  private handleError(error: any) {
296
  console.error('API Error:', error);
 
298
  if (error.status === 401) {
299
  // Token expired or invalid
300
  this.authService.logout();
301
+ } else if (error.status === 409) {
302
+ // Race condition error - add specific handling
303
+ const message = error.error?.detail || 'Resource was modified by another user';
304
+
305
+ // Create a more user-friendly error object
306
+ return throwError(() => ({
307
+ ...error,
308
+ userMessage: message,
309
+ requiresReload: true
310
+ }));
311
  }
312
 
313
  return throwError(() => error.error || error);