* Map HTTP status codes to error configurations * Following industry-standard error messages
(status: number)
| 179 | * Following industry-standard error messages |
| 180 | */ |
| 181 | private static getErrorConfig(status: number): Omit<AppErrorConfig, 'statusCode' | 'technicalDetails'> { |
| 182 | // 4xx Client Errors (permanent - no retry) |
| 183 | if (status === 400) { |
| 184 | return { |
| 185 | code: 'BAD_REQUEST', |
| 186 | message: 'Bad Request', |
| 187 | userMessage: 'Invalid request. Please check your input and try again.', |
| 188 | isRetryable: false, |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | if (status === 401) { |
| 193 | return { |
| 194 | code: 'UNAUTHORIZED', |
| 195 | message: 'Unauthorized', |
| 196 | userMessage: 'Your session has expired. Please log in again.', |
| 197 | isRetryable: false, |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | if (status === 403) { |
| 202 | return { |
| 203 | code: 'FORBIDDEN', |
| 204 | message: 'Forbidden', |
| 205 | userMessage: "You don't have permission to access this resource.", |
| 206 | isRetryable: false, |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | if (status === 404) { |
| 211 | return { |
| 212 | code: 'NOT_FOUND', |
| 213 | message: 'Not Found', |
| 214 | userMessage: 'The requested resource was not found. It may have been deleted.', |
| 215 | isRetryable: false, |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | if (status === 409) { |
| 220 | return { |
| 221 | code: 'CONFLICT', |
| 222 | message: 'Conflict', |
| 223 | userMessage: 'This action conflicts with existing data. Please check and try again.', |
| 224 | isRetryable: false, |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | if (status === 422) { |
| 229 | return { |
| 230 | code: 'VALIDATION_ERROR', |
| 231 | message: 'Validation Error', |
| 232 | userMessage: 'Validation failed. Please check your input.', |
| 233 | isRetryable: false, |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | if (status === 429) { |
| 238 | return { |