* Creates a standardized error response
(
error: Error,
status: ContentfulStatusCode,
timestamp: string,
details?: Record<string, unknown>,
code?: string,
)
| 253 | * Creates a standardized error response |
| 254 | */ |
| 255 | function createErrorResponse( |
| 256 | error: Error, |
| 257 | status: ContentfulStatusCode, |
| 258 | timestamp: string, |
| 259 | details?: Record<string, unknown>, |
| 260 | code?: string, |
| 261 | ): ErrorResponse { |
| 262 | return { |
| 263 | success: false, |
| 264 | error: { |
| 265 | message: error.message || getDefaultErrorMessage(status), |
| 266 | code: code ?? getErrorCode(status), |
| 267 | timestamp, |
| 268 | ...(details && { details }), |
| 269 | ...(!!error.cause && { cause: error.cause }), |
| 270 | }, |
| 271 | status, |
| 272 | }; |
| 273 | } |
| 274 | |
| 275 | function createValidationErrorResponse( |
| 276 | error: ValidationError, |
no test coverage detected