Skip to content

Commit cc52cff

Browse files
committed
Enhance error handling in runRescriptDep function
- Increased maxBuffer size to 1MB for better command execution. - Added specific error message for cases where the buffer limit is exceeded, guiding users on project size limitations.
1 parent d035851 commit cc52cff

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

vscode-rescriptdep/src/extension.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,20 @@ async function runRescriptDep(cliPath: string, args: string[], context?: vscode.
384384
// Restore the correct Promise-based implementation using cp.execFile
385385
return new Promise((resolve, reject) => {
386386
const command = cliPath;
387-
const options: cp.ExecFileOptions = {}; // Add options like cwd if needed later
387+
const options: cp.ExecFileOptions = {
388+
maxBuffer: 1024 * 1024 // 1MB buffer size
389+
};
388390

389391
cp.execFile(command, args, options, (error, stdout, stderr) => {
390392
if (error) {
391393
console.error(`rescriptdep stderr: ${stderr}`);
394+
395+
// Provide more specific error message for buffer exceeded case
396+
if (error.message.includes('maxBuffer')) {
397+
reject(new Error('The project has too many modules to visualize as a graph. This feature works best with smaller projects or when focusing on specific modules.'));
398+
return;
399+
}
400+
392401
// Include stderr in the rejection for better debugging
393402
reject(new Error(`Command failed: ${command} ${args.join(' ')}\n${error.message}\nStderr: ${stderr}`));
394403
return;

0 commit comments

Comments
 (0)