mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 15:03:16 +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) {
|
||||
logger.error(readFileOutput);
|
||||
return {
|
||||
result: readFileOutput,
|
||||
status: "error",
|
||||
};
|
||||
throw new Error(readFileOutput);
|
||||
}
|
||||
|
||||
let patchedContent: string | false;
|
||||
|
|
@ -85,10 +82,9 @@ export const applyPatchTool = tool(
|
|||
: { error: e }),
|
||||
});
|
||||
const errMessage = e instanceof Error ? e.message : "Unknown error";
|
||||
return {
|
||||
result: `FAILED TO APPLY PATCH: The diff could not be applied to file '${file_path}'.\n\nError: ${errMessage}`,
|
||||
status: "error",
|
||||
};
|
||||
throw new Error(
|
||||
`FAILED TO APPLY PATCH: The diff could not be applied to file '${file_path}'.\n\nError: ${errMessage}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -96,10 +92,9 @@ export const applyPatchTool = tool(
|
|||
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)}...`,
|
||||
);
|
||||
return {
|
||||
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)}...`,
|
||||
status: "error",
|
||||
};
|
||||
throw new 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)}...`,
|
||||
);
|
||||
}
|
||||
|
||||
const { success: writeFileSuccess, output: writeFileOutput } =
|
||||
|
|
@ -110,10 +105,7 @@ export const applyPatchTool = tool(
|
|||
logger.error("Failed to write file", {
|
||||
writeFileOutput,
|
||||
});
|
||||
return {
|
||||
result: writeFileOutput,
|
||||
status: "error",
|
||||
};
|
||||
throw new Error(writeFileOutput);
|
||||
}
|
||||
|
||||
let resultMessage = `Successfully applied diff to \`${file_path}\` and saved changes.`;
|
||||
|
|
|
|||
|
|
@ -62,10 +62,9 @@ export const shellTool = tool(
|
|||
error_result: response,
|
||||
input,
|
||||
});
|
||||
return {
|
||||
result: `Command failed. Exit code: ${response.exitCode}\nResult: ${response.result}\nStdout:\n${response.artifacts?.stdout}`,
|
||||
status: "error",
|
||||
};
|
||||
throw new Error(
|
||||
`Command failed. Exit code: ${response.exitCode}\nResult: ${response.result}\nStdout:\n${response.artifacts?.stdout}`,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
@ -79,10 +78,9 @@ export const shellTool = tool(
|
|||
input,
|
||||
error: errorFields,
|
||||
});
|
||||
return {
|
||||
result: `Command failed. Exit code: ${errorFields.exitCode}\nError: ${errorFields.result}\nStdout:\n${errorFields.artifacts?.stdout}`,
|
||||
status: "error",
|
||||
};
|
||||
throw new Error(
|
||||
`Command failed. Exit code: ${errorFields.exitCode}\nError: ${errorFields.result}\nStdout:\n${errorFields.artifacts?.stdout}`,
|
||||
);
|
||||
}
|
||||
|
||||
logger.error(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue