Conversation
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>
Contributor
There was a problem hiding this comment.
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
getErrorMessagefrom./error_helpers.cjs. - Replace two occurrences of
error instanceof Error ? error.message : String(error)withgetErrorMessage(error).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pelikhan
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR simplifies
actions/setup/js/extra_empty_commit.cjs— recently modified in #23155 — to use the existinggetErrorMessageutility fromerror_helpers.cjsinstead of duplicating the inline error extraction pattern.Files Simplified
actions/setup/js/extra_empty_commit.cjs— replaced two inlineerror instanceof Error ? error.message : String(error)expressions withgetErrorMessage(error)and added the corresponding importImprovements Made
Applied project standard error-handling pattern:
const { getErrorMessage } = require("./error_helpers.cjs");importerror instanceof Error ? error.message : String(error)(×2) withgetErrorMessage(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.cjsmissed 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'sgetErrorMessageis slightly more thorough than the inline ternary — it also handles objects with amessageproperty that aren'tErrorinstances — so this is a minor behavior improvement as well.Changes Based On
Testing
extra_empty_commit.test.cjs— all 35 tests passmake lint-cjs)make fmt-cjs)ErrorobjectsReview Focus
Please verify:
getErrorMessagereturnserror.messageforErrorinstances, 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.
search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter: