24 lines
795 B
Markdown
24 lines
795 B
Markdown
|
|
# Polish: Error Handling
|
||
|
|
|
||
|
|
## Find
|
||
|
|
- Silent catches: `grep -rn "catch.*=>.*{}" --include="*.vue" --include="*.ts" src/`
|
||
|
|
- Empty try/catch: `grep -rn "catch.*{$" -A1` looking for immediate `}`
|
||
|
|
- Missing error states in views: check each view has `errorMessage` ref
|
||
|
|
|
||
|
|
## Fix Pattern
|
||
|
|
```typescript
|
||
|
|
.catch((err) => {
|
||
|
|
console.error('[ComponentName] operation failed:', err)
|
||
|
|
errorMessage.value = err instanceof Error ? err.message : 'Operation failed'
|
||
|
|
})
|
||
|
|
```
|
||
|
|
|
||
|
|
Template: `<p v-if="errorMessage" class="text-red-400 text-sm mt-2">{{ errorMessage }}</p>`
|
||
|
|
|
||
|
|
## Backend
|
||
|
|
- Replace `unwrap_or_default()` on serialization with proper error propagation
|
||
|
|
- Consistent RPC error structure: `{ error: { code: string, message: string } }`
|
||
|
|
|
||
|
|
## Verify
|
||
|
|
Both should return zero: silent catches and empty catch blocks.
|