179 lines
4.0 KiB
Markdown
179 lines
4.0 KiB
Markdown
# Empty Catch Blocks — Implementation Plan
|
|
|
|
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development or superpowers:executing-plans.
|
|
|
|
**Goal:** Добавить логирование во все пустые catch-блоки (17 мест), убрать `// ignore` комментарии.
|
|
|
|
**Architecture:** В каждом catch добавить `console.warn` (клиент) или `request.log.error` (сервер) с контекстным сообщением. Минимальные, безопасные изменения.
|
|
|
|
**Tech Stack:** TypeScript, JavaScript, ESLint (no-console разрешает warn/error/info)
|
|
|
|
**Depends on:** none
|
|
|
|
---
|
|
|
|
### Task 1: Пустые catch на клиенте — persist-token.ts (3 места)
|
|
|
|
**Files:**
|
|
- Modify: `client/src/shared/model/persist-token.ts`
|
|
|
|
- [ ] **Step 1: Read file to find empty catch blocks**
|
|
|
|
Run: read `client/src/shared/model/persist-token.ts`
|
|
|
|
- [ ] **Step 2: Add console.warn to each catch**
|
|
|
|
Each `catch { /* ignore */ }` becomes:
|
|
```ts
|
|
catch (err) {
|
|
console.warn('[persist-token] Failed to ...', err)
|
|
}
|
|
```
|
|
|
|
Specific messages based on context:
|
|
- localStorage.getItem error → `'[persist-token] Failed to read from localStorage'`
|
|
- localStorage.setItem error → `'[persist-token] Failed to write to localStorage'`
|
|
- JSON.parse error → `'[persist-token] Failed to parse stored value'`
|
|
|
|
- [ ] **Step 3: Run lint**
|
|
|
|
Run: `cd client && npm run lint`
|
|
Expected: PASS
|
|
|
|
- [ ] **Step 4: Commit**
|
|
|
|
```bash
|
|
git add client/src/shared/model/persist-token.ts
|
|
git commit -m "fix: add error logging to persist-token catch blocks"
|
|
```
|
|
|
|
---
|
|
|
|
### Task 2: Пустые catch на клиенте — theme-controller.tsx (2 места)
|
|
|
|
**Files:**
|
|
- Modify: `client/src/shared/model/theme-controller.tsx`
|
|
|
|
- [ ] **Step 1: Read file**
|
|
|
|
Run: read `client/src/shared/model/theme-controller.tsx`
|
|
|
|
- [ ] **Step 2: Add console.warn to each catch**
|
|
|
|
```ts
|
|
catch (err) {
|
|
console.warn('[theme] Failed to ...', err)
|
|
}
|
|
```
|
|
|
|
- [ ] **Step 3: Run lint**
|
|
|
|
- [ ] **Step 4: Commit**
|
|
|
|
```bash
|
|
git add client/src/shared/model/theme-controller.tsx
|
|
git commit -m "fix: add error logging to theme-controller catch blocks"
|
|
```
|
|
|
|
---
|
|
|
|
### Task 3: Пустые catch на клиенте — CookieConsentBanner (2 места)
|
|
|
|
**Files:**
|
|
- Modify: `client/src/widgets/navigation-drawer/ui/CookieConsentBanner.tsx`
|
|
|
|
- [ ] **Step 1: Read file**
|
|
|
|
- [ ] **Step 2: Add console.warn**
|
|
|
|
```ts
|
|
catch (err) {
|
|
console.warn('[cookie-consent] Failed to ...', err)
|
|
}
|
|
```
|
|
|
|
- [ ] **Step 3: Run lint**
|
|
|
|
- [ ] **Step 4: Commit**
|
|
|
|
```bash
|
|
git add client/src/widgets/navigation-drawer/ui/CookieConsentBanner.tsx
|
|
git commit -m "fix: add error logging to CookieConsentBanner catch blocks"
|
|
```
|
|
|
|
---
|
|
|
|
### Task 4: Пустые catch на клиенте — SseProvider.tsx
|
|
|
|
**Files:**
|
|
- Modify: `client/src/app/SseProvider.tsx`
|
|
|
|
- [ ] **Step 1: Read file, find empty catch**
|
|
|
|
- [ ] **Step 2: Add console.warn**
|
|
|
|
```ts
|
|
catch (err) {
|
|
console.warn('[sse] Connection error:', err)
|
|
}
|
|
```
|
|
|
|
- [ ] **Step 3: Run lint**
|
|
|
|
- [ ] **Step 4: Commit**
|
|
|
|
```bash
|
|
git add client/src/app/SseProvider.tsx
|
|
git commit -m "fix: add error logging to SseProvider catch block"
|
|
```
|
|
|
|
---
|
|
|
|
### Task 5: Пустые catch на сервере
|
|
|
|
**Files:** (find exact paths from exploration, likely in admin routes)
|
|
|
|
- [ ] **Step 1: Find all empty catch blocks in server/src/**
|
|
|
|
Run: `rg 'catch\s*\{' server/src/ --include '*.js'`
|
|
|
|
- [ ] **Step 2: Add request.log.error to each**
|
|
|
|
```js
|
|
catch (err) {
|
|
request.log.error({ err }, 'Failed to [operation description]')
|
|
}
|
|
```
|
|
|
|
- [ ] **Step 3: Run lint**
|
|
|
|
Run: `cd server && npm run lint`
|
|
Expected: PASS
|
|
|
|
- [ ] **Step 4: Run tests**
|
|
|
|
Run: `cd server && npm test`
|
|
Expected: PASS
|
|
|
|
- [ ] **Step 5: Commit**
|
|
|
|
```bash
|
|
git add server/src/
|
|
git commit -m "fix: add error logging to server catch blocks"
|
|
```
|
|
|
|
---
|
|
|
|
### Task 6: Финальная проверка
|
|
|
|
- [ ] **Step 1: Run all lints + tests**
|
|
|
|
```bash
|
|
cd client && npm run lint && npm test
|
|
cd server && npm run lint && npm test
|
|
```
|
|
|
|
- [ ] **Step 2: Verify no new ESLint errors**
|
|
|
|
Expected: PASS all
|