Adds config directory existence check for error handling
Introduces a validation step to ensure the vault configuration directory is accessible. Throws a descriptive error if the directory is unavailable, improving error handling and initialization clarity for the plugin. Enhances stability by ensuring TempDirectoryManager functions only when prerequisites are satisfied.
This commit is contained in:
1 file changed
+6
@@ -333,6 +333,9 @@ export class PandocTypstConverter {
|
|||||||
if (this.pandocOptions.vaultBasePath) {
|
if (this.pandocOptions.vaultBasePath) {
|
||||||
// Use TempDirectoryManager for plugin temp directories
|
// Use TempDirectoryManager for plugin temp directories
|
||||||
const configDir = this.plugin?.app?.vault?.configDir;
|
const configDir = this.plugin?.app?.vault?.configDir;
|
||||||
|
if (!configDir) {
|
||||||
|
throw new Error('Unable to access vault configuration directory. Plugin may not be properly initialized.');
|
||||||
|
}
|
||||||
const tempManager = TempDirectoryManager.create(this.pandocOptions.vaultBasePath, configDir, undefined, this.plugin?.app);
|
const tempManager = TempDirectoryManager.create(this.pandocOptions.vaultBasePath, configDir, undefined, this.plugin?.app);
|
||||||
this.tempDir = await tempManager.ensureTempDir('pandoc');
|
this.tempDir = await tempManager.ensureTempDir('pandoc');
|
||||||
} else {
|
} else {
|
||||||
@@ -340,6 +343,9 @@ export class PandocTypstConverter {
|
|||||||
const pathUtils = new PathUtils(this.plugin.app);
|
const pathUtils = new PathUtils(this.plugin.app);
|
||||||
const vaultPath = pathUtils.getVaultPath();
|
const vaultPath = pathUtils.getVaultPath();
|
||||||
const configDir = this.plugin?.app?.vault?.configDir;
|
const configDir = this.plugin?.app?.vault?.configDir;
|
||||||
|
if (!configDir) {
|
||||||
|
throw new Error('Unable to access vault configuration directory. Plugin may not be properly initialized.');
|
||||||
|
}
|
||||||
const tempManager = new TempDirectoryManager({ vaultPath, configDir, app: this.plugin.app });
|
const tempManager = new TempDirectoryManager({ vaultPath, configDir, app: this.plugin.app });
|
||||||
this.tempDir = await tempManager.ensureTempDir('pandoc');
|
this.tempDir = await tempManager.ensureTempDir('pandoc');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user