mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-06 17:02:14 +00:00
fix: throw errors in tools (#75)
* throw errors * format --------- Co-authored-by: bracesproul <braceasproul@gmail.com>
This commit is contained in:
parent
a0b8aaa075
commit
d985ae4555
2 changed files with 14 additions and 24 deletions
|
|
@ -50,10 +50,7 @@ export const applyPatchTool = tool(
|
||||||
);
|
);
|
||||||
if (!readFileSuccess) {
|
if (!readFileSuccess) {
|
||||||
logger.error(readFileOutput);
|
logger.error(readFileOutput);
|
||||||
return {
|
throw new Error(readFileOutput);
|
||||||
result: readFileOutput,
|
|
||||||
status: "error",
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let patchedContent: string | false;
|
let patchedContent: string | false;
|
||||||
|
|
@ -85,10 +82,9 @@ export const applyPatchTool = tool(
|
||||||
: { error: e }),
|
: { error: e }),
|
||||||
});
|
});
|
||||||
const errMessage = e instanceof Error ? e.message : "Unknown error";
|
const errMessage = e instanceof Error ? e.message : "Unknown error";
|
||||||
return {
|
throw new Error(
|
||||||
result: `FAILED TO APPLY PATCH: The diff could not be applied to file '${file_path}'.\n\nError: ${errMessage}`,
|
`FAILED TO APPLY PATCH: The diff could not be applied to file '${file_path}'.\n\nError: ${errMessage}`,
|
||||||
status: "error",
|
);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,10 +92,9 @@ export const applyPatchTool = tool(
|
||||||
logger.error(
|
logger.error(
|
||||||
`FAILED TO APPLY PATCH: The diff could not be applied to file '${file_path}'. This may be due to an invalid diff format or conflicting changes with the file's current content. Original content length: ${readFileOutput.length}, Diff: ${diff.substring(0, 100)}...`,
|
`FAILED TO APPLY PATCH: The diff could not be applied to file '${file_path}'. This may be due to an invalid diff format or conflicting changes with the file's current content. Original content length: ${readFileOutput.length}, Diff: ${diff.substring(0, 100)}...`,
|
||||||
);
|
);
|
||||||
return {
|
throw new Error(
|
||||||
result: `FAILED TO APPLY PATCH: The diff could not be applied to file '${file_path}'. This may be due to an invalid diff format or conflicting changes with the file's current content. Original content length: ${readFileOutput.length}, Diff: ${diff.substring(0, 100)}...`,
|
`FAILED TO APPLY PATCH: The diff could not be applied to file '${file_path}'. This may be due to an invalid diff format or conflicting changes with the file's current content. Original content length: ${readFileOutput.length}, Diff: ${diff.substring(0, 100)}...`,
|
||||||
status: "error",
|
);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { success: writeFileSuccess, output: writeFileOutput } =
|
const { success: writeFileSuccess, output: writeFileOutput } =
|
||||||
|
|
@ -110,10 +105,7 @@ export const applyPatchTool = tool(
|
||||||
logger.error("Failed to write file", {
|
logger.error("Failed to write file", {
|
||||||
writeFileOutput,
|
writeFileOutput,
|
||||||
});
|
});
|
||||||
return {
|
throw new Error(writeFileOutput);
|
||||||
result: writeFileOutput,
|
|
||||||
status: "error",
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let resultMessage = `Successfully applied diff to \`${file_path}\` and saved changes.`;
|
let resultMessage = `Successfully applied diff to \`${file_path}\` and saved changes.`;
|
||||||
|
|
|
||||||
|
|
@ -62,10 +62,9 @@ export const shellTool = tool(
|
||||||
error_result: response,
|
error_result: response,
|
||||||
input,
|
input,
|
||||||
});
|
});
|
||||||
return {
|
throw new Error(
|
||||||
result: `Command failed. Exit code: ${response.exitCode}\nResult: ${response.result}\nStdout:\n${response.artifacts?.stdout}`,
|
`Command failed. Exit code: ${response.exitCode}\nResult: ${response.result}\nStdout:\n${response.artifacts?.stdout}`,
|
||||||
status: "error",
|
);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -79,10 +78,9 @@ export const shellTool = tool(
|
||||||
input,
|
input,
|
||||||
error: errorFields,
|
error: errorFields,
|
||||||
});
|
});
|
||||||
return {
|
throw new Error(
|
||||||
result: `Command failed. Exit code: ${errorFields.exitCode}\nError: ${errorFields.result}\nStdout:\n${errorFields.artifacts?.stdout}`,
|
`Command failed. Exit code: ${errorFields.exitCode}\nError: ${errorFields.result}\nStdout:\n${errorFields.artifacts?.stdout}`,
|
||||||
status: "error",
|
);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.error(
|
logger.error(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue