mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
Revert "feat: enhance error reporting with specific error types from Claude e…" (#179)
This reverts commit 1b94b9e5a8.
This commit is contained in:
@@ -147,7 +147,6 @@ async function run() {
|
|||||||
} | null = null;
|
} | null = null;
|
||||||
let actionFailed = false;
|
let actionFailed = false;
|
||||||
let errorDetails: string | undefined;
|
let errorDetails: string | undefined;
|
||||||
let errorSubtype: string | undefined;
|
|
||||||
|
|
||||||
// First check if prepare step failed
|
// First check if prepare step failed
|
||||||
const prepareSuccess = process.env.PREPARE_SUCCESS !== "false";
|
const prepareSuccess = process.env.PREPARE_SUCCESS !== "false";
|
||||||
@@ -167,40 +166,23 @@ async function run() {
|
|||||||
// Output file is an array, get the last element which contains execution details
|
// Output file is an array, get the last element which contains execution details
|
||||||
if (Array.isArray(outputData) && outputData.length > 0) {
|
if (Array.isArray(outputData) && outputData.length > 0) {
|
||||||
const lastElement = outputData[outputData.length - 1];
|
const lastElement = outputData[outputData.length - 1];
|
||||||
if (lastElement.type === "result") {
|
if (
|
||||||
// Extract execution details
|
lastElement.type === "result" &&
|
||||||
|
"cost_usd" in lastElement &&
|
||||||
|
"duration_ms" in lastElement
|
||||||
|
) {
|
||||||
executionDetails = {
|
executionDetails = {
|
||||||
cost_usd: lastElement.total_cost_usd,
|
cost_usd: lastElement.cost_usd,
|
||||||
duration_ms: lastElement.duration_ms,
|
duration_ms: lastElement.duration_ms,
|
||||||
duration_api_ms: lastElement.duration_api_ms,
|
duration_api_ms: lastElement.duration_api_ms,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check if this is an error result based on subtype
|
|
||||||
switch (lastElement.subtype) {
|
|
||||||
case "error_during_execution":
|
|
||||||
errorSubtype = "Error during execution";
|
|
||||||
// Override the actionFailed flag based on the result
|
|
||||||
actionFailed = true;
|
|
||||||
break;
|
|
||||||
case "error_max_turns":
|
|
||||||
errorSubtype = "Maximum turns exceeded";
|
|
||||||
actionFailed = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the Claude action failed (only if not already determined from result)
|
// Check if the Claude action failed
|
||||||
if (!actionFailed) {
|
|
||||||
const claudeSuccess = process.env.CLAUDE_SUCCESS !== "false";
|
const claudeSuccess = process.env.CLAUDE_SUCCESS !== "false";
|
||||||
actionFailed = !claudeSuccess;
|
actionFailed = !claudeSuccess;
|
||||||
}
|
|
||||||
|
|
||||||
// Use errorSubtype as errorDetails if no other error details are available
|
|
||||||
if (actionFailed && !errorDetails && errorSubtype) {
|
|
||||||
errorDetails = errorSubtype;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error reading output file:", error);
|
console.error("Error reading output file:", error);
|
||||||
// If we can't read the file, check for any failure markers
|
// If we can't read the file, check for any failure markers
|
||||||
|
|||||||
@@ -114,16 +114,6 @@ export function updateCommentBody(input: CommentUpdateInput): string {
|
|||||||
|
|
||||||
if (actionFailed) {
|
if (actionFailed) {
|
||||||
header = "**Claude encountered an error";
|
header = "**Claude encountered an error";
|
||||||
|
|
||||||
// Add error type to header if available
|
|
||||||
if (errorDetails) {
|
|
||||||
if (errorDetails === "Error during execution") {
|
|
||||||
header = "**Claude encountered an error during execution";
|
|
||||||
} else if (errorDetails === "Maximum turns exceeded") {
|
|
||||||
header = "**Claude exceeded the maximum number of turns";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (durationStr) {
|
if (durationStr) {
|
||||||
header += ` after ${durationStr}`;
|
header += ` after ${durationStr}`;
|
||||||
}
|
}
|
||||||
@@ -191,13 +181,8 @@ export function updateCommentBody(input: CommentUpdateInput): string {
|
|||||||
// Build the new body with blank line between header and separator
|
// Build the new body with blank line between header and separator
|
||||||
let newBody = `${header}${links}`;
|
let newBody = `${header}${links}`;
|
||||||
|
|
||||||
// Add error details if available (but not if it's just the error type we already showed in header)
|
// Add error details if available
|
||||||
if (
|
if (actionFailed && errorDetails) {
|
||||||
actionFailed &&
|
|
||||||
errorDetails &&
|
|
||||||
errorDetails !== "Error during execution" &&
|
|
||||||
errorDetails !== "Maximum turns exceeded"
|
|
||||||
) {
|
|
||||||
newBody += `\n\n\`\`\`\n${errorDetails}\n\`\`\``;
|
newBody += `\n\n\`\`\`\n${errorDetails}\n\`\`\``;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user