ai-spector 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +173 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/analyze.d.ts +9 -0
  8. package/dist/commands/analyze.d.ts.map +1 -0
  9. package/dist/commands/analyze.js +62 -0
  10. package/dist/commands/analyze.js.map +1 -0
  11. package/dist/commands/bootstrap.d.ts +4 -0
  12. package/dist/commands/bootstrap.d.ts.map +1 -0
  13. package/dist/commands/bootstrap.js +58 -0
  14. package/dist/commands/bootstrap.js.map +1 -0
  15. package/dist/commands/graph-impact.d.ts +10 -0
  16. package/dist/commands/graph-impact.d.ts.map +1 -0
  17. package/dist/commands/graph-impact.js +31 -0
  18. package/dist/commands/graph-impact.js.map +1 -0
  19. package/dist/commands/graph-merge.d.ts +11 -0
  20. package/dist/commands/graph-merge.d.ts.map +1 -0
  21. package/dist/commands/graph-merge.js +88 -0
  22. package/dist/commands/graph-merge.js.map +1 -0
  23. package/dist/commands/graph-query.d.ts +10 -0
  24. package/dist/commands/graph-query.d.ts.map +1 -0
  25. package/dist/commands/graph-query.js +31 -0
  26. package/dist/commands/graph-query.js.map +1 -0
  27. package/dist/commands/graph-visualize.d.ts +10 -0
  28. package/dist/commands/graph-visualize.d.ts.map +1 -0
  29. package/dist/commands/graph-visualize.js +72 -0
  30. package/dist/commands/graph-visualize.js.map +1 -0
  31. package/dist/commands/init.d.ts +6 -0
  32. package/dist/commands/init.d.ts.map +1 -0
  33. package/dist/commands/init.js +47 -0
  34. package/dist/commands/init.js.map +1 -0
  35. package/dist/commands/validate.d.ts +10 -0
  36. package/dist/commands/validate.d.ts.map +1 -0
  37. package/dist/commands/validate.js +89 -0
  38. package/dist/commands/validate.js.map +1 -0
  39. package/dist/config/load.d.ts +21 -0
  40. package/dist/config/load.d.ts.map +1 -0
  41. package/dist/config/load.js +77 -0
  42. package/dist/config/load.js.map +1 -0
  43. package/dist/config/types.d.ts +22 -0
  44. package/dist/config/types.d.ts.map +1 -0
  45. package/dist/config/types.js +2 -0
  46. package/dist/config/types.js.map +1 -0
  47. package/dist/graph/InMemoryGraph.d.ts +20 -0
  48. package/dist/graph/InMemoryGraph.d.ts.map +1 -0
  49. package/dist/graph/InMemoryGraph.js +181 -0
  50. package/dist/graph/InMemoryGraph.js.map +1 -0
  51. package/dist/graph/defaults.d.ts +10 -0
  52. package/dist/graph/defaults.d.ts.map +1 -0
  53. package/dist/graph/defaults.js +10 -0
  54. package/dist/graph/defaults.js.map +1 -0
  55. package/dist/graph/impact.d.ts +32 -0
  56. package/dist/graph/impact.d.ts.map +1 -0
  57. package/dist/graph/impact.js +88 -0
  58. package/dist/graph/impact.js.map +1 -0
  59. package/dist/graph/knowledge.d.ts +53 -0
  60. package/dist/graph/knowledge.d.ts.map +1 -0
  61. package/dist/graph/knowledge.js +79 -0
  62. package/dist/graph/knowledge.js.map +1 -0
  63. package/dist/graph/load.d.ts +4 -0
  64. package/dist/graph/load.d.ts.map +1 -0
  65. package/dist/graph/load.js +12 -0
  66. package/dist/graph/load.js.map +1 -0
  67. package/dist/graph/loadGraph.d.ts +3 -0
  68. package/dist/graph/loadGraph.d.ts.map +1 -0
  69. package/dist/graph/loadGraph.js +7 -0
  70. package/dist/graph/loadGraph.js.map +1 -0
  71. package/dist/graph/merge.d.ts +15 -0
  72. package/dist/graph/merge.d.ts.map +1 -0
  73. package/dist/graph/merge.js +63 -0
  74. package/dist/graph/merge.js.map +1 -0
  75. package/dist/graph/query.d.ts +18 -0
  76. package/dist/graph/query.d.ts.map +1 -0
  77. package/dist/graph/query.js +132 -0
  78. package/dist/graph/query.js.map +1 -0
  79. package/dist/registry/build.d.ts +3 -0
  80. package/dist/registry/build.d.ts.map +1 -0
  81. package/dist/registry/build.js +53 -0
  82. package/dist/registry/build.js.map +1 -0
  83. package/dist/registry/slug.d.ts +4 -0
  84. package/dist/registry/slug.d.ts.map +1 -0
  85. package/dist/registry/slug.js +16 -0
  86. package/dist/registry/slug.js.map +1 -0
  87. package/dist/types.d.ts +45 -0
  88. package/dist/types.d.ts.map +1 -0
  89. package/dist/types.js +2 -0
  90. package/dist/types.js.map +1 -0
  91. package/dist/util/fs.d.ts +6 -0
  92. package/dist/util/fs.d.ts.map +1 -0
  93. package/dist/util/fs.js +24 -0
  94. package/dist/util/fs.js.map +1 -0
  95. package/dist/util/paths.d.ts +16 -0
  96. package/dist/util/paths.d.ts.map +1 -0
  97. package/dist/util/paths.js +19 -0
  98. package/dist/util/paths.js.map +1 -0
  99. package/dist/visualize/html.d.ts +13 -0
  100. package/dist/visualize/html.d.ts.map +1 -0
  101. package/dist/visualize/html.js +374 -0
  102. package/dist/visualize/html.js.map +1 -0
  103. package/dist/visualize/stats.d.ts +21 -0
  104. package/dist/visualize/stats.d.ts.map +1 -0
  105. package/dist/visualize/stats.js +45 -0
  106. package/dist/visualize/stats.js.map +1 -0
  107. package/documents.json +64 -0
  108. package/package.json +65 -0
  109. package/scaffold/.ai-spector/.docflow/config/analyze.graphify.json +40 -0
  110. package/scaffold/.ai-spector/.docflow/config/completeness-rules.basic-design.json +18 -0
  111. package/scaffold/.ai-spector/.docflow/config/completeness-rules.detail-design.json +57 -0
  112. package/scaffold/.ai-spector/.docflow/config/completeness-rules.srs.json +72 -0
  113. package/scaffold/.ai-spector/.docflow/config/dag.basic-design.json +38 -0
  114. package/scaffold/.ai-spector/.docflow/config/dag.detail-design.json +64 -0
  115. package/scaffold/.ai-spector/.docflow/config/dag.srs.json +87 -0
  116. package/scaffold/.ai-spector/.docflow/config/data-source.json +5 -0
  117. package/scaffold/.ai-spector/.docflow/config/index.docs.json +22 -0
  118. package/scaffold/.ai-spector/.docflow/config/workflow.dependencies.json +271 -0
  119. package/scaffold/.ai-spector/.docflow/extract/patch.example.json +20 -0
  120. package/scaffold/.ai-spector/.docflow/state.json +11 -0
  121. package/scaffold/.ai-spector/docflow.config.json +7 -0
  122. package/scaffold/.ai-spector/index/README.md +18 -0
  123. package/scaffold/.ai-spector/index/basic-design.md +5 -0
  124. package/scaffold/.ai-spector/index/srs.md +5 -0
  125. package/scaffold/.cursor/commands/_cli-failures.md +110 -0
  126. package/scaffold/.cursor/commands/_graph.md +48 -0
  127. package/scaffold/.cursor/commands/_prerequisites.md +48 -0
  128. package/scaffold/.cursor/commands/_workflow.md +50 -0
  129. package/scaffold/.cursor/commands/analyze.md +92 -0
  130. package/scaffold/.cursor/commands/generate-basic-design.md +26 -0
  131. package/scaffold/.cursor/commands/generate-detail-design.md +19 -0
  132. package/scaffold/.cursor/commands/generate-srs.md +63 -0
  133. package/scaffold/.cursor/commands/graph-impact.md +45 -0
  134. package/scaffold/.cursor/commands/index-docs.md +36 -0
  135. package/scaffold/.cursor/commands/sync-graph.md +30 -0
  136. package/scaffold/.cursor/commands/validate-graph.md +28 -0
  137. package/scaffold/.cursor/commands/visualize-graph.md +24 -0
  138. package/scaffold/.cursor/skills/ai-spector/SKILL.md +39 -0
  139. package/scaffold/docs/data-source/README.md +7 -0
  140. package/schemas/rules.impact.json +17 -0
  141. package/schemas/rules.traceability.json +30 -0
  142. package/schemas/schema.extract-patch.json +19 -0
  143. package/schemas/schema.graph.json +83 -0
  144. package/schemas/schema.knowledge.json +107 -0
  145. package/templates/basic_design/db-design-template.md +177 -0
  146. package/templates/basic_design/detail-api-template.md +278 -0
  147. package/templates/basic_design/detail-screen-template.md +281 -0
  148. package/templates/basic_design/list-api-template.md +130 -0
  149. package/templates/basic_design/list-screen-template.md +242 -0
  150. package/templates/detail_design/common/architecture-overview-template.md +302 -0
  151. package/templates/detail_design/common/deployment-infrastructure-template.md +461 -0
  152. package/templates/detail_design/common/error-handling-patterns-template.md +460 -0
  153. package/templates/detail_design/common/integration-patterns-template.md +410 -0
  154. package/templates/detail_design/common/performance-standards-template.md +406 -0
  155. package/templates/detail_design/common/security-patterns-template.md +395 -0
  156. package/templates/detail_design/feature-detail-design-template.md +773 -0
  157. package/templates/detail_design/feature-list-template.md +39 -0
  158. package/templates/srs/1-introduction.md +58 -0
  159. package/templates/srs/2-overall-description.md +91 -0
  160. package/templates/srs/3-use-case-detail-template.md +142 -0
  161. package/templates/srs/3-use-cases.md +53 -0
  162. package/templates/srs/4-system-feature-detail-template.md +131 -0
  163. package/templates/srs/4-system-features-list-template.md +39 -0
  164. package/templates/srs/5-data-requirements.md +59 -0
  165. package/templates/srs/6-external-interfaces.md +56 -0
  166. package/templates/srs/7-quality-attributes.md +74 -0
  167. package/templates/srs/8-internationalization.md +36 -0
  168. package/templates/srs/9-other-requirements.md +46 -0
@@ -0,0 +1,460 @@
1
+ # Error Handling Patterns: <Project Name>
2
+
3
+ > This document defines standard error handling patterns, error codes, exception handling strategies, and user-facing error messages used across all features.
4
+
5
+ **Source Requirements:** SRS Section 7 (Quality Attributes - Reliability)
6
+
7
+ ---
8
+
9
+ ## 1. Overview
10
+
11
+ **Purpose:**
12
+ > This document establishes error handling standards that ensure consistent error responses, proper logging, and good user experience across all features.
13
+
14
+ **Error Handling Principles:**
15
+ - Fail fast and fail clearly
16
+ - Provide meaningful error messages
17
+ - Log errors for debugging
18
+ - Don't expose sensitive information
19
+ - Handle errors gracefully
20
+
21
+ ---
22
+
23
+ ## 2. Standard Error Response Format
24
+
25
+ ### 2.1 API Error Response
26
+
27
+ **Standard Format:**
28
+ ```json
29
+ {
30
+ "error": {
31
+ "code": "ERROR_CODE",
32
+ "message": "Human-readable error message",
33
+ "details": {
34
+ "field": "Additional error details",
35
+ "timestamp": "2025-01-15T10:30:00Z",
36
+ "request_id": "req_123456789"
37
+ },
38
+ "errors": [
39
+ {
40
+ "field": "email",
41
+ "message": "Invalid email format"
42
+ }
43
+ ]
44
+ }
45
+ }
46
+ ```
47
+
48
+ **HTTP Status Codes:**
49
+ - `400 Bad Request`: Client error (validation, malformed request)
50
+ - `401 Unauthorized`: Authentication required
51
+ - `403 Forbidden`: Insufficient permissions
52
+ - `404 Not Found`: Resource not found
53
+ - `409 Conflict`: Resource conflict (duplicate, constraint violation)
54
+ - `422 Unprocessable Entity`: Validation errors
55
+ - `429 Too Many Requests`: Rate limit exceeded
56
+ - `500 Internal Server Error`: Server error
57
+ - `503 Service Unavailable`: Service temporarily unavailable
58
+
59
+ ### 2.2 Error Response Fields
60
+
61
+ | Field | Type | Required | Description |
62
+ |-------|------|----------|-------------|
63
+ | `error.code` | string | Yes | Machine-readable error code |
64
+ | `error.message` | string | Yes | Human-readable error message |
65
+ | `error.details` | object | No | Additional error context |
66
+ | `error.errors` | array | No | Field-specific validation errors |
67
+ | `error.timestamp` | string | Yes | ISO 8601 timestamp |
68
+ | `error.request_id` | string | Yes | Unique request identifier for tracing |
69
+
70
+ ---
71
+
72
+ ## 3. Error Code Taxonomy
73
+
74
+ ### 3.1 Error Code Format
75
+
76
+ **Format:** `<CATEGORY>_<SUBCATEGORY>_<SPECIFIC>`
77
+
78
+ **Categories:**
79
+ - `VALIDATION`: Input validation errors
80
+ - `AUTHENTICATION`: Authentication failures
81
+ - `AUTHORIZATION`: Authorization failures
82
+ - `NOT_FOUND`: Resource not found
83
+ - `CONFLICT`: Resource conflicts
84
+ - `EXTERNAL`: External service errors
85
+ - `INTERNAL`: Internal server errors
86
+ - `RATE_LIMIT`: Rate limiting errors
87
+
88
+ ### 3.2 Common Error Codes
89
+
90
+ **Validation Errors:**
91
+ - `VALIDATION_REQUIRED`: Required field missing
92
+ - `VALIDATION_INVALID_FORMAT`: Invalid format
93
+ - `VALIDATION_OUT_OF_RANGE`: Value out of allowed range
94
+ - `VALIDATION_DUPLICATE`: Duplicate value not allowed
95
+
96
+ **Authentication Errors:**
97
+ - `AUTH_INVALID_CREDENTIALS`: Invalid username/password
98
+ - `AUTH_TOKEN_EXPIRED`: Authentication token expired
99
+ - `AUTH_TOKEN_INVALID`: Invalid authentication token
100
+ - `AUTH_REQUIRED`: Authentication required
101
+
102
+ **Authorization Errors:**
103
+ - `AUTHZ_INSUFFICIENT_PERMISSIONS`: User lacks required permissions
104
+ - `AUTHZ_RESOURCE_FORBIDDEN`: Access to resource forbidden
105
+ - `AUTHZ_ROLE_REQUIRED`: Specific role required
106
+
107
+ **Not Found Errors:**
108
+ - `NOT_FOUND_RESOURCE`: Resource not found
109
+ - `NOT_FOUND_ENDPOINT`: API endpoint not found
110
+
111
+ **Conflict Errors:**
112
+ - `CONFLICT_DUPLICATE`: Duplicate resource
113
+ - `CONFLICT_STATE`: Invalid state for operation
114
+ - `CONFLICT_CONCURRENT_MODIFICATION`: Concurrent modification detected
115
+
116
+ **External Service Errors:**
117
+ - `EXTERNAL_SERVICE_UNAVAILABLE`: External service unavailable
118
+ - `EXTERNAL_SERVICE_TIMEOUT`: External service timeout
119
+ - `EXTERNAL_SERVICE_ERROR`: External service error
120
+
121
+ **Internal Errors:**
122
+ - `INTERNAL_SERVER_ERROR`: Internal server error
123
+ - `INTERNAL_DATABASE_ERROR`: Database error
124
+ - `INTERNAL_PROCESSING_ERROR`: Processing error
125
+
126
+ **Rate Limit Errors:**
127
+ - `RATE_LIMIT_EXCEEDED`: Rate limit exceeded
128
+ - `RATE_LIMIT_QUOTA_EXCEEDED`: Quota exceeded
129
+
130
+ ---
131
+
132
+ ## 4. Exception Handling Strategy
133
+
134
+ ### 4.1 Exception Hierarchy
135
+
136
+ **Exception Types:**
137
+ ```
138
+ BaseException
139
+ ├── ValidationException
140
+ │ ├── RequiredFieldException
141
+ │ ├── InvalidFormatException
142
+ │ └── OutOfRangeException
143
+ ├── AuthenticationException
144
+ │ ├── InvalidCredentialsException
145
+ │ └── TokenExpiredException
146
+ ├── AuthorizationException
147
+ │ └── InsufficientPermissionsException
148
+ ├── NotFoundException
149
+ ├── ConflictException
150
+ │ └── DuplicateResourceException
151
+ ├── ExternalServiceException
152
+ │ ├── ServiceUnavailableException
153
+ │ └── ServiceTimeoutException
154
+ └── InternalException
155
+ ├── DatabaseException
156
+ └── ProcessingException
157
+ ```
158
+
159
+ ### 4.2 Exception Handling Flow
160
+
161
+ ```mermaid
162
+ flowchart TD
163
+ Request[API Request] --> Validation{Input Validation}
164
+ Validation -->|Valid| BusinessLogic[Business Logic]
165
+ Validation -->|Invalid| ValidationError[ValidationException]
166
+ BusinessLogic -->|Success| Response[Success Response]
167
+ BusinessLogic -->|Error| ExceptionHandler[Exception Handler]
168
+ ExceptionHandler -->|Known Exception| MapError[Map to Error Code]
169
+ ExceptionHandler -->|Unknown Exception| LogError[Log Error]
170
+ MapError --> ErrorResponse[Error Response]
171
+ LogError --> GenericError[Generic Error Response]
172
+ ErrorResponse --> Client[Client]
173
+ GenericError --> Client
174
+ ```
175
+
176
+ ### 4.3 Exception Handling Best Practices
177
+
178
+ **Do:**
179
+ - Catch specific exceptions
180
+ - Log errors with context
181
+ - Return appropriate HTTP status codes
182
+ - Provide meaningful error messages
183
+ - Include request ID for tracing
184
+
185
+ **Don't:**
186
+ - Expose internal implementation details
187
+ - Return stack traces to clients
188
+ - Log sensitive information
189
+ - Swallow exceptions silently
190
+ - Return generic "Something went wrong" messages
191
+
192
+ ---
193
+
194
+ ## 5. User-Facing Error Messages
195
+
196
+ ### 5.1 Message Guidelines
197
+
198
+ **Principles:**
199
+ - Clear and concise
200
+ - Actionable when possible
201
+ - User-friendly language
202
+ - Avoid technical jargon
203
+ - Don't blame the user
204
+
205
+ ### 5.2 Message Examples
206
+
207
+ **Good Messages:**
208
+ - "Please enter a valid email address"
209
+ - "Password must be at least 8 characters long"
210
+ - "This email is already registered. Please sign in or use a different email"
211
+ - "We couldn't find the page you're looking for"
212
+
213
+ **Bad Messages:**
214
+ - "Error 500"
215
+ - "Invalid input"
216
+ - "Database connection failed"
217
+ - "Null pointer exception"
218
+
219
+ ### 5.3 Localization
220
+
221
+ **Error Message Localization:**
222
+ - Store error messages in resource files
223
+ - Support multiple languages
224
+ - Use message keys for consistency
225
+ - Provide default fallback messages
226
+
227
+ ---
228
+
229
+ ## 6. Logging and Monitoring
230
+
231
+ ### 6.1 Error Logging
232
+
233
+ **Log Levels:**
234
+ - **ERROR**: Errors that require attention but don't stop the system
235
+ - **CRITICAL**: Critical errors that may stop the system
236
+ - **WARNING**: Warnings that may indicate problems
237
+
238
+ **Log Format:**
239
+ ```json
240
+ {
241
+ "timestamp": "2025-01-15T10:30:00Z",
242
+ "level": "ERROR",
243
+ "error_code": "VALIDATION_INVALID_FORMAT",
244
+ "message": "Invalid email format",
245
+ "request_id": "req_123456789",
246
+ "user_id": "user123",
247
+ "ip_address": "192.168.1.1",
248
+ "stack_trace": "...",
249
+ "context": {
250
+ "field": "email",
251
+ "value": "invalid-email"
252
+ }
253
+ }
254
+ ```
255
+
256
+ ### 6.2 Error Monitoring
257
+
258
+ **Monitoring Metrics:**
259
+ - Error rate by error code
260
+ - Error rate by endpoint
261
+ - Error rate over time
262
+ - Response time for error cases
263
+
264
+ **Alerting:**
265
+ - Critical error threshold exceeded
266
+ - Unusual error pattern detected
267
+ - Error rate spike detected
268
+
269
+ ---
270
+
271
+ ## 7. Retry and Recovery Patterns
272
+
273
+ ### 7.1 Retry Strategy
274
+
275
+ **When to Retry:**
276
+ - Transient errors (network timeouts, temporary service unavailability)
277
+ - Rate limit errors (with backoff)
278
+ - External service errors
279
+
280
+ **When NOT to Retry:**
281
+ - Client errors (4xx)
282
+ - Authentication/authorization errors
283
+ - Validation errors
284
+ - Permanent failures
285
+
286
+ ### 7.2 Retry Configuration
287
+
288
+ **Retry Parameters:**
289
+ - Max Retries: <Number, e.g., 3>
290
+ - Initial Delay: <Duration, e.g., 100ms>
291
+ - Backoff Strategy: <Exponential/Linear>
292
+ - Max Delay: <Duration, e.g., 5s>
293
+
294
+ **Exponential Backoff Example:**
295
+ ```
296
+ Attempt 1: Wait 100ms
297
+ Attempt 2: Wait 200ms
298
+ Attempt 3: Wait 400ms
299
+ Attempt 4: Wait 800ms
300
+ ```
301
+
302
+ ### 7.3 Circuit Breaker Pattern
303
+
304
+ **Circuit Breaker States:**
305
+ - **Closed**: Normal operation
306
+ - **Open**: Failing, reject requests immediately
307
+ - **Half-Open**: Testing if service recovered
308
+
309
+ **Configuration:**
310
+ - Failure Threshold: <Number of failures to open circuit>
311
+ - Timeout: <Duration before attempting recovery>
312
+ - Success Threshold: <Number of successes to close circuit>
313
+
314
+ ---
315
+
316
+ ## 8. Error Handling by Layer
317
+
318
+ ### 8.1 Client-Side Error Handling
319
+
320
+ **Responsibilities:**
321
+ - Display user-friendly error messages
322
+ - Handle network errors
323
+ - Retry failed requests when appropriate
324
+ - Show loading states
325
+ - Handle validation errors
326
+
327
+ ### 8.2 API Gateway Error Handling
328
+
329
+ **Responsibilities:**
330
+ - Validate request format
331
+ - Handle authentication errors
332
+ - Rate limiting
333
+ - Request/response transformation
334
+ - Error response formatting
335
+
336
+ ### 8.3 Application Layer Error Handling
337
+
338
+ **Responsibilities:**
339
+ - Business logic validation
340
+ - Exception catching and mapping
341
+ - Error logging
342
+ - Error response generation
343
+
344
+ ### 8.4 Database Layer Error Handling
345
+
346
+ **Responsibilities:**
347
+ - Handle database connection errors
348
+ - Handle constraint violations
349
+ - Handle transaction errors
350
+ - Map database errors to application errors
351
+
352
+ ---
353
+
354
+ ## 9. Error Handling Examples
355
+
356
+ ### 9.1 Validation Error Example
357
+
358
+ **Request:**
359
+ ```http
360
+ POST /api/users
361
+ Content-Type: application/json
362
+
363
+ {
364
+ "email": "invalid-email",
365
+ "age": -5
366
+ }
367
+ ```
368
+
369
+ **Response:**
370
+ ```http
371
+ HTTP/1.1 422 Unprocessable Entity
372
+ Content-Type: application/json
373
+
374
+ {
375
+ "error": {
376
+ "code": "VALIDATION_ERROR",
377
+ "message": "Validation failed",
378
+ "timestamp": "2025-01-15T10:30:00Z",
379
+ "request_id": "req_123456789",
380
+ "errors": [
381
+ {
382
+ "field": "email",
383
+ "message": "Invalid email format"
384
+ },
385
+ {
386
+ "field": "age",
387
+ "message": "Age must be a positive number"
388
+ }
389
+ ]
390
+ }
391
+ }
392
+ ```
393
+
394
+ ### 9.2 Authentication Error Example
395
+
396
+ **Request:**
397
+ ```http
398
+ GET /api/users/me
399
+ Authorization: Bearer invalid_token
400
+ ```
401
+
402
+ **Response:**
403
+ ```http
404
+ HTTP/1.1 401 Unauthorized
405
+ Content-Type: application/json
406
+
407
+ {
408
+ "error": {
409
+ "code": "AUTH_TOKEN_INVALID",
410
+ "message": "Invalid authentication token",
411
+ "timestamp": "2025-01-15T10:30:00Z",
412
+ "request_id": "req_123456789"
413
+ }
414
+ }
415
+ ```
416
+
417
+ ### 9.3 Not Found Error Example
418
+
419
+ **Request:**
420
+ ```http
421
+ GET /api/users/999
422
+ ```
423
+
424
+ **Response:**
425
+ ```http
426
+ HTTP/1.1 404 Not Found
427
+ Content-Type: application/json
428
+
429
+ {
430
+ "error": {
431
+ "code": "NOT_FOUND_RESOURCE",
432
+ "message": "User not found",
433
+ "timestamp": "2025-01-15T10:30:00Z",
434
+ "request_id": "req_123456789"
435
+ }
436
+ }
437
+ ```
438
+
439
+ ---
440
+
441
+ ## 10. References
442
+
443
+ **Related Documents:**
444
+ - [Security Patterns](../common/security-patterns-template.md)
445
+ - [Feature Detail Design Template](../feature-detail-design-template.md)
446
+
447
+ **SRS References:**
448
+ - SRS Section 7: Quality Attributes - Reliability
449
+
450
+ ---
451
+
452
+ ## 11. Notes
453
+
454
+ **Error Handling Considerations:**
455
+ - <Consideration 1>
456
+ - <Consideration 2>
457
+
458
+ **Future Enhancements:**
459
+ - <Enhancement 1>
460
+ - <Enhancement 2>