Skip to content

Commit 86d8d05

Browse files
committed
fix(migration): handle migration error for custom instructions
- Wrap file write and global state update in try-catch block - Log error message if migration fails
1 parent 7aab01d commit 86d8d05

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/utils/migrateSettings.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,15 @@ export async function migrateSettings(
4040
const customInstructionsFilePath = path.join(settingsDir, GlobalFileNames.customInstructions)
4141

4242
if (customInstructionsContent && !(await fileExistsAtPath(customInstructionsFilePath))) {
43-
await fs.writeFile(customInstructionsFilePath, customInstructionsContent, "utf-8")
44-
await context.globalState.update(customInstructionsKey, undefined) // Delete from GlobalState
45-
outputChannel.appendLine("Migrated custom instructions from GlobalState to file.")
43+
try {
44+
await fs.writeFile(customInstructionsFilePath, customInstructionsContent, "utf-8")
45+
await context.globalState.update(customInstructionsKey, undefined) // Delete from GlobalState
46+
outputChannel.appendLine("Migrated custom instructions from GlobalState to file.")
47+
} catch (migrationError) {
48+
outputChannel.appendLine(
49+
`Error migrating custom instructions: ${migrationError}. Data might still be in GlobalState.`,
50+
)
51+
}
4652
} else {
4753
outputChannel.appendLine(
4854
`Skipping custom instructions migration: ${customInstructionsContent ? "file already exists" : "no data in GlobalState"}`,

0 commit comments

Comments
 (0)