Skip to content

Conversation

github-actions[bot]
Copy link

@github-actions github-actions bot commented Jul 1, 2025

Closes #310

Applied changes based on Issue #310.

I’ve enabled strict unknown typing for all catch variables and wired in a small helper to safely stringify them. Changes include:

• tsconfig.json
– Turned on "useUnknownInCatchVariables": true to make all catch params unknown.

• src/utils/error.ts
– New module exporting
toErrorMessage(error: unknown): string
toErrorStack(error: unknown): string|undefined

• src/main.ts
– Imported the new helpers and unified the top‐level catch to always use toErrorMessage/toErrorStack.

• src/file/file.ts
– Imported toErrorMessage and protected all unguarded ${error} in its catch blocks.

• src/github/event.ts
– Imported toErrorMessage and wrapped the JSON‐parse error in toErrorMessage.

• src/github/github.ts
– Imported toErrorMessage, and updated several raw core.error(\…${error}`)andthrow new Error(`…${error}`)` sites to use the helper instead.

• src/security/security.ts
– Imported toErrorMessage and switched its two core.warning(\…${error}`)calls totoErrorMessage(error)`.

All existing catch‐blocks that already narrow via instanceof Error remain, but any raw ${error} is now safe.

Next steps:

  1. Run npm run format to apply Prettier.
  2. Build/compile (npm run build) and verify no TypeScript errors.
  3. Run the full test suite (npm test).

@YiweiShen YiweiShen merged commit 1eb31d1 into main Jul 1, 2025
@YiweiShen YiweiShen deleted the codez-chore-310-refactor-error-handling-use-unknown-in-catch-blocks-3025402042 branch July 1, 2025 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use unknown in catch blocks

1 participant