danvk / source-map-explorer

Analyze and debug space usage through source maps
Apache License 2.0
3.83k stars 101 forks source link

Enhancement: Give error message rather than crashing on ENOENT #50

Closed ShadSterling closed 7 years ago

ShadSterling commented 7 years ago

I had a path wrong and typed source-map-explorer main.bundle.js, which yielded this:

fs.js:584
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open 'main.bundle.js'
    at Object.fs.openSync (fs.js:584:18)
    at Object.fs.readFileSync (fs.js:491:33)
    at loadSourceMap (/Users/ssterling3/.npm-global/lib/node_modules/source-map-explorer/index.js:81:19)
    at Object.<anonymous> (/Users/ssterling3/.npm-global/lib/node_modules/source-map-explorer/index.js:159:12)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)

At first I thought the install was broken, and almost reported a bug that it doesn't work on install. But no, I just had to type source-map-explorer dist/main.bundle.js.

It would be better if a missing file resulted in a simple error message.

danvk commented 7 years ago

Makes sense. Want to send a PR? On Wed, May 10, 2017 at 3:10 PM Shad Sterling notifications@github.com wrote:

I had a path wrong and typed source-map-explorer main.bundle.js, which yielded this:

fs.js:584 return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); ^

Error: ENOENT: no such file or directory, open 'main.bundle.js' at Object.fs.openSync (fs.js:584:18) at Object.fs.readFileSync (fs.js:491:33) at loadSourceMap (/Users/ssterling3/.npm-global/lib/node_modules/source-map-explorer/index.js:81:19) at Object. (/Users/ssterling3/.npm-global/lib/node_modules/source-map-explorer/index.js:159:12) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.runMain (module.js:605:10)

At first I thought the install was broken, and almost reported a bug that it doesn't work on install. But no, I just had to type source-map-explorer dist/main.bundle.js.

It would be better if a missing file resulted in a simple error message.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/danvk/source-map-explorer/issues/50, or mute the thread https://github.com/notifications/unsubscribe-auth/AAF__cy9in2xANp8x-wJ6B78vrM6Mlmwks5r4gufgaJpZM4NXGKZ .