opencode-usage-coach 0.11.3 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +24 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -231,8 +231,30 @@ function effectiveFrameworks(frameworks, keyDeps) {
|
|
|
231
231
|
async function ghFetch(url, signal) {
|
|
232
232
|
const res = await fetch(url, { headers: ghHeaders(), signal });
|
|
233
233
|
if (!res.ok) {
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
let ghError = null;
|
|
235
|
+
let ghErrorText = "";
|
|
236
|
+
try {
|
|
237
|
+
ghErrorText = await res.text();
|
|
238
|
+
ghError = JSON.parse(ghErrorText);
|
|
239
|
+
} catch {
|
|
240
|
+
}
|
|
241
|
+
const tag = res.status === 403 || res.status === 429 ? " (rate limit)" : res.status === 422 ? " (validation failed)" : "";
|
|
242
|
+
const errs = ghError?.errors;
|
|
243
|
+
const errMsg = ghError?.message ?? ghErrorText.slice(0, 300);
|
|
244
|
+
const detail = errs ? errs.map((e) => typeof e === "string" ? e : `${e?.field ?? "?"}: ${e?.message ?? e?.code ?? JSON.stringify(e)}`).join("; ") : "";
|
|
245
|
+
console.error(JSON.stringify({
|
|
246
|
+
level: "error",
|
|
247
|
+
module: "web-search",
|
|
248
|
+
event: "gh-fetch-error",
|
|
249
|
+
status: res.status,
|
|
250
|
+
tag,
|
|
251
|
+
url,
|
|
252
|
+
ghMessage: errMsg,
|
|
253
|
+
ghErrors: detail,
|
|
254
|
+
rateLimitRemaining: res.headers.get("x-ratelimit-remaining"),
|
|
255
|
+
rateLimitReset: res.headers.get("x-ratelimit-reset")
|
|
256
|
+
}));
|
|
257
|
+
throw new Error(`HTTP ${res.status}${tag}: ${errMsg}${detail ? ` | ${detail}` : ""}`);
|
|
236
258
|
}
|
|
237
259
|
return await res.json();
|
|
238
260
|
}
|
package/package.json
CHANGED