Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'error' of undefined #22

Closed
LaurensRietveld opened this issue Feb 5, 2020 · 2 comments
Closed

Cannot read property 'error' of undefined #22

LaurensRietveld opened this issue Feb 5, 2020 · 2 comments

Comments

@LaurensRietveld
Copy link

I've got a test.nt file that contains this line:

<A-Ha:Top/Arts/Music/Bands_and_Artists/A/A-Ha> <http://dmoz.org/rdf/Target> <http://jena.cvs.sourceforge.net/viewvc/*checkout*/jena/jena-perf/data/Top/Arts/Music/Bands_and_Artists/A/A-Ha> .

When I run this script:

const fs = require('fs');
const nt_read = require('@graphy/content.nt.read');

let count = 0;
fs.createReadStream('test.nt')
    .pipe(nt_read())
    .on('data', (y_quad) => {
	count++;
    })
    .on('error', console.error)
    .on('eof', () => {
        console.log('done!', count);
    });

Then I get this error:

TypeError: Cannot read property 'error' of undefined
    at create_named_node_escapeless (/scratch/lrd900/node/node_modules/@graphy/content.nt.read/main.js:300:66)
    at Reader.statement (/scratch/lrd900/node/node_modules/@graphy/content.nt.read/main.js:635:20)
    at Reader.parse (/scratch/lrd900/node/node_modules/@graphy/content.nt.read/main.js:519:21)
    at NTriples_Reader.transform [as _transform] (/scratch/lrd900/node/node_modules/@graphy/content.nt.read/main.js:370:11)
    at NTriples_Reader.Transform._read (/scratch/lrd900/node/node_modules/readable-stream/lib/_stream_transform.js:177:10)
    at NTriples_Reader.Transform._write (/scratch/lrd900/node/node_modules/readable-stream/lib/_stream_transform.js:164:83)
    at doWrite (/scratch/lrd900/node/node_modules/readable-stream/lib/_stream_writable.js:409:139)
    at writeOrBuffer (/scratch/lrd900/node/node_modules/readable-stream/lib/_stream_writable.js:398:5)
    at NTriples_Reader.Writable.write (/scratch/lrd900/node/node_modules/readable-stream/lib/_stream_writable.js:307:11)
    at ReadStream.ondata (_stream_readable.js:728:22)
@blake-regalia
Copy link
Owner

blake-regalia commented Feb 5, 2020

Fixed in v4.0.4.

The reader will now err about the invalid IRI, which can either be caught in the 'error' event handler, or bypassed altogether using the relax option to the reader to skip IRI validation. Is this the behavior you expected?

@LaurensRietveld
Copy link
Author

That's what I'd expect indeed, thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants