Skip to content

[code-simplifier] refactor: use getErrorMessage helper in extra_empty_commit.cjs (#23155 follow-up)#23211

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
code-simplifier/extra-empty-commit-error-helper-2026-03-27-86df40a2c2729f1f
Draft

[code-simplifier] refactor: use getErrorMessage helper in extra_empty_commit.cjs (#23155 follow-up)#23211
github-actions[bot] wants to merge 1 commit intomainfrom
code-simplifier/extra-empty-commit-error-helper-2026-03-27-86df40a2c2729f1f

Conversation

@github-actions
Copy link
Contributor

This PR simplifies actions/setup/js/extra_empty_commit.cjs — recently modified in #23155 — to use the existing getErrorMessage utility from error_helpers.cjs instead of duplicating the inline error extraction pattern.

Files Simplified

  • actions/setup/js/extra_empty_commit.cjs — replaced two inline error instanceof Error ? error.message : String(error) expressions with getErrorMessage(error) and added the corresponding import

Improvements Made

Applied project standard error-handling pattern:

  • Added const { getErrorMessage } = require("./error_helpers.cjs"); import
  • Replaced error instanceof Error ? error.message : String(error) (×2) with getErrorMessage(error)

This is already the established pattern across 15+ other files in actions/setup/js/ (e.g., add_comment.cjs, add_labels.cjs, validate_secrets.cjs). extra_empty_commit.cjs missed this helper because it was added before the helper was introduced (or was added independently), and PR #23155 introduced two new instances of the inline pattern.

Note: error_helpers.cjs's getErrorMessage is slightly more thorough than the inline ternary — it also handles objects with a message property that aren't Error instances — so this is a minor behavior improvement as well.

Changes Based On

Testing

  • extra_empty_commit.test.cjs — all 35 tests pass
  • ✅ Linting passes (make lint-cjs)
  • ✅ Formatting passes (make fmt-cjs)
  • ✅ No functional changes — error message output is identical for standard Error objects

Review Focus

Please verify:

  • The import and two replacement usages are correct
  • Behavior is preserved (it is: getErrorMessage returns error.message for Error instances, same as the inline ternary)

Automated by Code Simplifier Agent — analyzing code from the last 24 hours

References: §23633534943

Note

🔒 Integrity filter blocked 1 item

The following item were blocked because they don't meet the GitHub integrity level.

  • #23074 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

Generated by Code Simplifier ·

  • expires on Mar 28, 2026, 6:14 AM UTC

Replace inline `error instanceof Error ? error.message : String(error)`
with the existing `getErrorMessage` utility from error_helpers.cjs,
consistent with the pattern used throughout the codebase.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants