visionmedia / bytes.js

node byte string parser
MIT License
461 stars 57 forks source link

improve string error message #13

Closed dougwilson closed 9 years ago

dougwilson commented 10 years ago

It would be nice if the error message for an unknown parse would be nicer. Currently it is a bit confusing, I think:

$ node -pe 'require("bytes")("56r")'

node_modules\bytes\index.js:13
    , n = parseFloat(parts[1])
                          ^
TypeError: Cannot read property '1' of null
    at module.exports (node_modules\bytes\index.js:13:27)
    at [eval]:1:17
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:456:26)
    at evalScript (node.js:532:25)
    at startup (node.js:80:7)
    at node.js:902:3
theofidry commented 9 years ago

Fixed in my fork https://github.com/theofidry/bytes.js, waiting for merge.

dougwilson commented 9 years ago

@tj do you feel like added me to the npm module :)?

theofidry commented 9 years ago

Hm after some thoughts I'm still changing a few things. It will be up in an hour I think.

theofidry commented 9 years ago

@tj @dougwilson Ok it should be good, cf PR #20. Should not cause any backward incompatibility.