ethereumjs/keythereum

A way to handle error and log

peskic93 opened this issue · 6 comments

Is there a way to disable logs like path where address data is saved after creation?
Also I cannot catch error, it just logs it in console which is a bit annoying.

keythereum.js:421 
Uncaught Error: message authentication code mismatch
    at verifyAndDecrypt (keythereum.js:421)
    at keythereum.js:445
    at keythereum.js:278
    at keythereum.js:30847
    at Item.run (keythereum.js:31226)
    at drainQueue (keythereum.js:31196)

and

Saved to file:
/home/user/parity/keys/chain/UTC--2018-03-01T15:32:02.766Z--c7a168b127181d4b8750aa4015058ff530b8c8b6
To use with geth, copy this file to your Ethereum keystore folder (usually ~/.ethereum/keystore).

I guess that console.log() and console.error() are used and I think it's not a good idea.

Hi, I'm not the maintainer of this library, but - yes - you are right, output is done by console.log:
https://github.com/ethereumjs/keythereum/search?utf8=%E2%9C%93&q=console&type=

This is not optimal. Requires some lib updates though in terms of passing options, not sure if anyone has capacity for this atm.

Silur commented

@tinybike
do we have an ES5-only policy on this repo? or refactoring error handling to ES6 promises works?

Yes @Silur it's currently ES5. IMO it's a sufficiently simple library that the benefits of switching to ES6 are pretty small. I agree that it'd be nice to add proper logging, would definitely welcome a PR that did so!

Aren't you using babel here anyhow for distribution so it shouldn't be a problem to use ES6 features?

Well, if you guys want to do the legwork of converting to ES6, I won't stand in your way :)

@peskic93 if you set keythereum.constants.quiet = true, it will not print out that "Saved to file" message. But AFAIK there's no real reason to have that message displayed at all, so I've simply removed it in the latest patch (1.0.4). Also fixed the un-catchable error; thanks for pointing that out!