pilwon / node-yahoo-finance

Yahoo Finance historical quotes and snapshot data downloader written in Node.js
491 stars 123 forks source link

CSV column mis-alignment error #6

Closed joeyvmason closed 10 years ago

joeyvmason commented 10 years ago

When retrieving these fields,

['p5', 'r', 'p6', 'y', 'p', 'j4', 'e', 's6', 'j1', 'b4'], occasionally this error below is thrown. It's an assertion error. I'm unable to catch it, so it crashes my app. It seems like it would be better if instead of throwing an assertion error, the error message could just end up in the err object in the callback?

The code:

try {
    yahooFinance.snapshot({
        symbols: [stock.symbol],
        fields: ['p5', 'r', 'p6', 'y', 'p', 'j4', 'e', 's6', 'j1', 'b4']
    }, function (err, data, url, fields) {
              // do something
    }
  } catch (error) {
          // handle the error
  }

The error message:

assert.js:92
  throw new assert.AssertionError({
    ^
AssertionError: CSV column mis-alignment error
    at /Users/joeyvmason/Development/finance/finance/node_modules/yahoo-finance/lib/index.js:320:11
    at Function.map (/Users/joeyvmason/Development/finance/finance/node_modules/yahoo-finance/node_modules/lodash/dist/lodash.js:3250:27)
    at /Users/joeyvmason/Development/finance/finance/node_modules/yahoo-finance/lib/index.js:296:23
    at null.<anonymous> (/Users/joeyvmason/Development/finance/finance/node_modules/csv/lib/to.js:277:14)
    at EventEmitter.emit (events.js:95:17)
    at null.<anonymous> (/Users/joeyvmason/Development/finance/finance/node_modules/csv/lib/index.js:214:17)
    at EventEmitter.emit (events.js:92:17)
    at Transformer.end (/Users/joeyvmason/Development/finance/finance/node_modules/csv/lib/transformer.js:241:17)
    at null.<anonymous> (/Users/joeyvmason/Development/finance/finance/node_modules/csv/lib/index.js:198:29)
    at EventEmitter.emit (events.js:95:17)

pilwon commented 10 years ago

@joeyvmason Try again with yahoo-finance@0.1.3