davidchambers / tutor

JavaScript interface for the Gatherer card database
https://gatherer.wizards.com/
Do What The F*ck You Want To Public License
149 stars 18 forks source link

Uncatchable exception? #90

Closed FullR closed 9 years ago

FullR commented 9 years ago

I'm unable to catch the error that results from passing an invalid name into tutor.card. This is my test:

function test() {
    try {
        console.log("Fetching");
        tutor.card({name: "fizzbuzzldspla"}, function(error, card) {
            if(error) {
                console.log("ERROR: " + error);
            }
            console.log(card);
        });
    } catch(error) {
        console.log("Caught: " + error);
    }
}
test();

The output:

Fetching
/home/james/projects/mtg/node_modules/tutor/lib/gatherer/card.js:149
s?[)]$/.exec($('.textRating').text().replace(/\s+/g, '')), _i = _ref.length - 
                                                                    ^
TypeError: Cannot read property 'length' of null
    at extract (/home/james/projects/mtg/node_modules/tutor/lib/gatherer/card.js:149:128)
    at /home/james/projects/mtg/node_modules/tutor/lib/gatherer/card.js:24:24
    at Request._callback (/home/james/projects/mtg/node_modules/tutor/lib/gatherer.js:62:16)
    at Request.self.callback (/home/james/projects/mtg/node_modules/tutor/node_modules/request/request.js:122:22)
    at Request.emit (events.js:110:17)
    at Request.<anonymous> (/home/james/projects/mtg/node_modules/tutor/node_modules/request/request.js:1019:14)
    at Request.emit (events.js:129:20)
    at IncomingMessage.<anonymous> (/home/james/projects/mtg/node_modules/tutor/node_modules/request/request.js:970:12)
    at IncomingMessage.emit (events.js:129:20)
    at _stream_readable.js:908:16
    at process._tickCallback (node.js:355:11)

Tutor version 0.0.6 Node version 0.12.3

davidchambers commented 9 years ago

Fixed in v0.7.0 :)