@@ -4,6 +4,7 @@ import { getUriPathBasename } from "../../util/uri";
44import { ToolImpl } from "." ;
55import { getNumberArg , getStringArg } from "../parseArgs" ;
66import { throwIfFileExceedsHalfOfContext } from "./readFileLimit" ;
7+ import { ContinueError , ContinueErrorReason } from "../../util/errors" ;
78
89export const readFileRangeImpl : ToolImpl = async ( args , extras ) => {
910 const filepath = getStringArg ( args , "filepath" ) ;
@@ -12,24 +13,28 @@ export const readFileRangeImpl: ToolImpl = async (args, extras) => {
1213
1314 // Validate that line numbers are positive integers
1415 if ( startLine < 1 ) {
15- throw new Error (
16+ throw new ContinueError (
17+ ContinueErrorReason . InvalidLineNumber ,
1618 "startLine must be 1 or greater. Negative line numbers are not supported - use the terminal tool with 'tail' command for reading from file end." ,
1719 ) ;
1820 }
1921 if ( endLine < 1 ) {
20- throw new Error (
22+ throw new ContinueError (
23+ ContinueErrorReason . InvalidLineNumber ,
2124 "endLine must be 1 or greater. Negative line numbers are not supported - use the terminal tool with 'tail' command for reading from file end." ,
2225 ) ;
2326 }
2427 if ( endLine < startLine ) {
25- throw new Error (
28+ throw new ContinueError (
29+ ContinueErrorReason . InvalidLineNumber ,
2630 `endLine (${ endLine } ) must be greater than or equal to startLine (${ startLine } )` ,
2731 ) ;
2832 }
2933
3034 const firstUriMatch = await resolveRelativePathInDir ( filepath , extras . ide ) ;
3135 if ( ! firstUriMatch ) {
32- throw new Error (
36+ throw new ContinueError (
37+ ContinueErrorReason . FileNotFound ,
3338 `File "${ filepath } " does not exist. You might want to check the path and try again.` ,
3439 ) ;
3540 }
0 commit comments