History

Yield tagged workspace read errors directly

Cursor Agent committed 4 months ago

Commit 201f6541 parent 7f891481 file · +16 −22Browse files

Showing the changes to apps/server/src/workspace/WorkspaceFileSystem.ts (1 of 1 file). Show all

Unified · Split

apps/server/src/workspace/WorkspaceFileSystem.ts+16−22
@@ -135,26 +135,22 @@ export const make = Effect.gen(function* () { · 134 unmodified lines
135135 relativeRealPath === ".." ||
136136 path.isAbsolute(relativeRealPath)
137137 ) {
138− return yield* Effect.fail(
139− new WorkspaceReadFileResolvedOutsideRootError({
140− cwd: input.cwd,
141− relativePath: target.relativePath,
142− realWorkspaceRoot,
143− realTargetPath,
144− }),
145− );
138+ return yield* new WorkspaceReadFileResolvedOutsideRootError({
139+ cwd: input.cwd,
140+ relativePath: target.relativePath,
141+ realWorkspaceRoot,
142+ realTargetPath,
143+ });
146144 }
147145
148146 const handle = yield* fileSystem.open(realTargetPath, { flag: "r" });
149147 const stat = yield* handle.stat;
150148 if (stat.type !== "File") {
151− return yield* Effect.fail(
152− new WorkspaceReadFileNotFileError({
153− cwd: input.cwd,
154− relativePath: target.relativePath,
155− fileType: stat.type,
156− }),
157− );
149+ return yield* new WorkspaceReadFileNotFileError({
150+ cwd: input.cwd,
151+ relativePath: target.relativePath,
152+ fileType: stat.type,
153+ });
158154 }
159155 const byteLength = Number(stat.size);
160156 const bytesToRead = Math.min(byteLength, PROJECT_READ_FILE_MAX_BYTES);
@@ -163,13 +159,11 @@ export const make = Effect.gen(function* () { · 2 unmodified lines
163159 const fileBytes = buffer.subarray(0, Number(bytesRead));
164160 const nulByteOffset = fileBytes.indexOf(0);
165161 if (nulByteOffset !== -1) {
166− return yield* Effect.fail(
167− new WorkspaceReadFileBinaryFileError({
168− cwd: input.cwd,
169− relativePath: target.relativePath,
170− nulByteOffset,
171− }),
172− );
162+ return yield* new WorkspaceReadFileBinaryFileError({
163+ cwd: input.cwd,
164+ relativePath: target.relativePath,
165+ nulByteOffset,
166+ });
173167 }
174168 const contents = new TextDecoder("utf-8").decode(fileBytes);
175169 return {