MCPcopy Create free account
hub / github.com/github/gh-aw / getErrorMessage

Function getErrorMessage

actions/setup/js/error_helpers.cjs:26–44  ·  view source on GitHub ↗

* Safely extract an error message from an unknown error value. * Handles Error instances, objects with message properties, and other values. * * When the extracted message looks like an HTML page (e.g. GitHub's "Unicorn" * 504 error page), it is replaced with a concise human-readable description

(error)

Source from the content-addressed store, hash-verified

24 * @returns {string} The error message as a string
25 */
26function getErrorMessage(error) {
27 // prettier-ignore
28 const errorAsAny = /** @type {any} */ (error);
29 let message;
30 if (error instanceof Error) {
31 message = error.message;
32 } else if (error && typeof error === "object" && "message" in error && typeof error.message === "string") {
33 message = error.message;
34 } else {
35 message = String(error);
36 }
37
38 if (isHtmlContent(message)) {
39 const status = errorAsAny != null && typeof errorAsAny.status === "number" ? errorAsAny.status : null;
40 return status != null ? `GitHub returned an unexpected HTML response (HTTP ${status})` : "GitHub returned an unexpected HTML response";
41 }
42
43 return message;
44}
45
46/**
47 * Check if an error is due to a locked issue/PR/discussion.

Callers 15

mainFunction · 0.70
getSubIssueCountFunction · 0.70
mainFunction · 0.70
appendEntryFunction · 0.70
fetchAndLogRateLimitFunction · 0.70
ensureParentIssueFunction · 0.70
linkSubIssueFunction · 0.70
loadMissingDataMessagesFunction · 0.70
loadMissingToolMessagesFunction · 0.70

Calls 1

isHtmlContentFunction · 0.85

Tested by

no test coverage detected