Skip to content

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

Merged
pelikhan merged 1 commit intomainfrom
code-simplifier/extra-empty-commit-error-helper-2026-03-27-86df40a2c2729f1f
Mar 27, 2026
Merged

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

Conversation

@github-actions
Copy link
Copy Markdown
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>
@pelikhan pelikhan marked this pull request as ready for review March 27, 2026 18:01
Copilot AI review requested due to automatic review settings March 27, 2026 18:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors actions/setup/js/extra_empty_commit.cjs to use the shared getErrorMessage helper for consistent error-message extraction, removing duplicated inline logic.

Changes:

  • Import getErrorMessage from ./error_helpers.cjs.
  • Replace two occurrences of error instanceof Error ? error.message : String(error) with getErrorMessage(error).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pelikhan pelikhan merged commit d6f0a0f into main Mar 27, 2026
64 checks passed
@pelikhan pelikhan deleted the code-simplifier/extra-empty-commit-error-helper-2026-03-27-86df40a2c2729f1f branch March 27, 2026 18:57
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.

2 participants