Skip to content

Commit 33a7c51

Browse files
committed
Update claude.md
1 parent c6ebc50 commit 33a7c51

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,18 @@ Socket CLI integrates with various third-party tools and services:
185185
- **Array length checks**: Use `!array.length` instead of `array.length === 0`. For `array.length > 0`, use `!!array.length` when function must return boolean, or `array.length` when used in conditional contexts
186186
- **Catch parameter naming**: Use `catch (e)` instead of `catch (error)` for consistency across the codebase
187187

188+
### Error Handling
189+
- **Input validation errors**: Use `InputError` from `src/utils/errors.mts` for user input validation failures (missing files, invalid arguments, etc.)
190+
- **Authentication errors**: Use `AuthError` from `src/utils/errors.mts` for API authentication issues
191+
- **CResult pattern**: Use `CResult<T>` type for functions that can fail, following the Result/Either pattern with `ok: true/false`
192+
- **Process exit**: Avoid `process.exit(1)` unless absolutely necessary; prefer throwing appropriate error types that the CLI framework handles
193+
- **Error messages**: Write clear, actionable error messages that help users understand what went wrong and how to fix it
194+
- **Examples**:
195+
-`throw new InputError('No .socket directory found in current directory')`
196+
-`throw new AuthError('Invalid API token')`
197+
-`logger.error('Error occurred'); return` (doesn't set proper exit code)
198+
-`process.exit(1)` (bypasses error handling framework)
199+
188200
### Safe File Operations
189201
- **File deletion**: NEVER use `rm -rf` for deleting files or directories. Always use `npx trash-cli` instead for safer deletion with recovery options
190202
- **Examples**:

0 commit comments

Comments
 (0)