@@ -273,7 +273,6 @@ export class LocalStore implements Source, RdfJsStore {
273273 for await ( const graph of graphIterator ) {
274274 if ( hasEnded ) return
275275 graphIterations ++
276-
277276 if ( ! this . #graphIsCached( graph ) ) await this . #cacheGraph( graph )
278277 const graphStream = this . #cache. match (
279278 /** @ts -ignore */
@@ -319,7 +318,7 @@ export class LocalStore implements Source, RdfJsStore {
319318 */
320319 #graphIsCached( graph : NamedNode | DefaultGraph ) {
321320 /** @ts -expect-error we are using N3s internal API */
322- return this . #cache. _termToNumericId ( graph ) !== undefined
321+ return this . #cache. _graphs [ this . #cache . _termToNumericId ( graph ) ] !== undefined
323322 }
324323
325324 /**
@@ -345,11 +344,15 @@ export class LocalStore implements Source, RdfJsStore {
345344 * The actual function that parses a file on disk and puts it into the N3 store.
346345 */
347346 async #parseAndStoreGraph( graph : NamedNode | DefaultGraph , fileHandle : FileSystemFileHandle ) {
348- const parser = new Parser ( { baseIRI : graph . value } )
349- const contents = await ( await fileHandle . getFile ( ) ) . text ( )
350- const strippedContents = contents . replace ( / \< ( [ a - z . \/ # ] * ) \. t t l ( [ a - z . \/ # ] * ) \> / g, '<$1$2>' )
351- const quads = await parser . parse ( strippedContents )
352- this . #cache. addQuads ( quads . map ( quad => factory . quad ( quad . subject , quad . predicate , quad . object , graph ) ) )
347+ try {
348+ const parser = new Parser ( { baseIRI : graph . value } )
349+ const contents = await ( await fileHandle . getFile ( ) ) . text ( )
350+ const strippedContents = contents . replace ( / < ( .| \/ ) ( .* ) \. t t l ( .* ) > / g, '<$1$2>' )
351+ const quads = await parser . parse ( strippedContents )
352+ this . #cache. addQuads ( quads . map ( quad => factory . quad ( quad . subject , quad . predicate , quad . object , graph ) ) )
353+ } catch ( error : any ) {
354+ throw new Error ( `Error while parsing graph ${ graph . value } :` + error . message )
355+ }
353356 }
354357
355358 /**
0 commit comments