fix: improve VFS initialization error messages and documentation

- Add helpful error message when VFS not initialized
- Include example code in error message showing correct initialization
- Add VFS_INITIALIZATION.md documentation guide
- Add tests for VFS initialization patterns
- Clarify that brain.vfs() is a method, not a property
This commit is contained in:
David Snelling 2025-09-26 14:27:46 -07:00
parent 29ecf8c271
commit 1259b66525
3 changed files with 335 additions and 1 deletions

View file

@ -884,7 +884,13 @@ export class VirtualFileSystem implements IVirtualFileSystem {
private async ensureInitialized(): Promise<void> {
if (!this.initialized) {
throw new Error('VFS not initialized. Call init() first.')
throw new Error(
'VFS not initialized. You must call await vfs.init() after getting the VFS instance.\n' +
'Example:\n' +
' const vfs = brain.vfs() // Note: vfs() is a method, not a property\n' +
' await vfs.init() // This creates the root directory\n' +
'See docs: https://github.com/Brainy-Technologies/brainy/blob/main/docs/vfs/QUICK_START.md'
)
}
}