I use the module omdb and I have some trouble catching errors when using it. The error is caused by one of the two methods below, but the stacktrace does not show which. Furthermore, none of the console.logs fires either, so I assume that I've made some mistake trying to handle possible errors. The description for omdb.poster is:
Returns a readable stream of the poster JPEG.
function downloadImage(show, callback) {
var filename = show.title + + " " + show.year + ".jpg";
var path = "./images/" + filename;
omdb.poster(show)
.pipe(fs.createWriteStream(path))
.on('error', function(err) {
console.log("Download Omdb image err: " + err + " for " + show.title + " " + show.year);
callback(err, null);
})
.on('close', function() {
callback(null, path);
});
}
function getOmdbInfo(show, callback) {
omdb.get(show, true, function(err, movie) {
if(err) {
console.log("err:" + show.title + " " + show.year);
callback(err, null);
}
if(!movie) {
console.log("No OMDB info results for: " + show.title + " " + show.year);
callback('Movie not found!', null);
} else {
callback(null, movie);
}
});
}
Error:
\node_modules\needle\lib\needle.js:81
throw new TypeError('URL must be a string, not ' + uri);
^
TypeError: URL must be a string, not null
at Object.Needle.request (\node
_modules\omdb\node_modules\needle\lib\needle.js:81:13)
at Object.exports.(anonymous function) [as get] (\node_modules\omdb\node_modules\needle\lib\needle.js:425:19)
at \node_modules\omdb\index.js:251:26
at \node_modules\omdb\index.js:198:13
at done (\node_modules\omdb\node_modules\needle\lib\needle.js:234:9)
at PassThrough.<anonymous> (\node_modules\needle\lib\needle.js:363:11)
at PassThrough.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
showvariable?var show = {title: title, year: year};example{title: "Fargo", year: 2004}