Skip to content

Commit 89469dd

Browse files
kotlrainshen49
authored andcommitted
Add better error handling for Firestore permissions and Terraform errors
1 parent f518b38 commit 89469dd

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/app/app.component.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ export class AppComponent {
170170
this.isLoading.set(false);
171171
}
172172

173-
handleError(error: any, userMessage: string): void {
173+
handleError(error: any, userMessage: string, duration: number = 3000): void {
174174
console.error('Error:', error);
175175
this.snackBar.open(userMessage, 'Close', {
176-
duration: 3000,
176+
duration,
177177
});
178178
}
179179

@@ -226,10 +226,11 @@ export class AppComponent {
226226
}));
227227
},
228228
error: (error: any) => {
229-
console.error('Error loading subtasks:', error);
230-
this.snackBar.open('Error loading subtasks', 'Close', {
231-
duration: 3000,
232-
});
229+
if (error.message.indexOf('Missing or insufficient permissions') >= 0) {
230+
this.handleError(error, 'Check Firestore permissions in Firebase Console at: https://console.firebase.google.com/project/_/firestore/databases/-default-/rules', 10000);
231+
} else {
232+
this.handleError(error, 'Failed to load subtasks.');
233+
}
233234
},
234235
});
235236
})
@@ -347,7 +348,11 @@ export class AppComponent {
347348
this.openEditor(newTask);
348349
} catch (error) {
349350
if (error instanceof GoogleGenerativeAIFetchError) {
350-
this.handleError(error, error.message);
351+
if (error.message.indexOf('API key not valid') > 0) {
352+
this.handleError(error, 'Error loading Gemini API key. Please rerun Terraform with `terraform apply --auto-approve`', 10000);
353+
} else {
354+
this.handleError(error, error.message);
355+
}
351356
} else {
352357
this.handleError(error, 'Failed to generate main task.');
353358
}

0 commit comments

Comments
 (0)