-
Notifications
You must be signed in to change notification settings - Fork 1
Update CI builds #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update CI builds #21
Changes from all commits
f3894d8
43544ed
b3af705
a05a543
e0ce38e
c650071
8a391ae
acc5a3a
10ece2c
0153f0c
acde9d8
021a227
07181b3
3cd4bcd
f75fccd
f91fe9a
4d721f4
68be2c6
ea88f83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,26 +31,37 @@ export function errorHandler( | |
| ): void { | ||
| const errorId = generateErrorId(); | ||
|
|
||
| // Extract error properties with safe type handling. | ||
| // We accept Error | unknown and need to safely access properties that may exist | ||
| // on Error objects (message), HTTP error objects (statusCode, status), or custom | ||
| // error objects (code). Type casting to any is necessary to access these | ||
| // arbitrary properties while maintaining runtime safety through optional chaining. | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| const errorObj = err as any; // Allow accessing arbitrary properties | ||
| const errorMessage = errorObj?.message ?? String(err); | ||
| const errorType = errorObj?.constructor?.name ?? 'Unknown'; | ||
| const statusCode = errorObj?.statusCode ?? errorObj?.status ?? 500; | ||
| const errorCode = errorObj?.code; | ||
|
|
||
| // Log the full error internally with correlation ID (safe location) | ||
| log.error({ | ||
| message: 'API error', | ||
| data: { | ||
| errorId, | ||
| type: err?.constructor?.name || 'Unknown', | ||
| message: err?.message || String(err) | ||
| type: errorType, | ||
| message: errorMessage | ||
| } | ||
| }); | ||
|
|
||
| // Return safe error response to client with error ID for tracing | ||
| const statusCode = err?.statusCode || err?.status || 500; | ||
| const errorResponse: ErrorResponse = { | ||
| error: 'An error occurred processing your request', | ||
| errorId | ||
| }; | ||
|
|
||
| // Add code if it's a validation error or known error type | ||
| if (err?.code) { | ||
| errorResponse.code = err.code; | ||
| if (errorCode) { | ||
| errorResponse.code = errorCode; | ||
| } | ||
|
|
||
| res.status(statusCode).json(errorResponse); | ||
|
Comment on lines
+43
to
67
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment in the build step (lines 60-61) indicates this is a duplicate build step that should potentially be removed. The build command runs in both the 'test' job and implicitly in the 'build-and-push' job via Docker. Consider whether this duplication serves a specific purpose or if it can be streamlined to avoid wasting CI resources and time.