lucaswerkmeister / m3api

minimal modern MediaWiki API client

Home Page:https://www.npmjs.com/package/m3api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Show warnings by default

lucaswerkmeister opened this issue · comments

Currently, the Node backend doesn’t show warnings by default, because I was worried about printing warnings in a CLI application; I had a vague idea to, some time after the 1.0 release, do a code search for m3api users, and consider showing warnings by default in a future 2.0 version if it looked like this wouldn’t cause much breakage.

After thinking this over for a bit longer, I think I’ve changed my mind: API warnings are important enough that they should be shown by default. Most users of the library won’t be CLI applications, and the benefit to those users of printing warnings by default should outweigh the risk of confusing users of CLI applications. Also, this will make example / model code for m3api shorter, since we won’t need to include warn: console.warn anymore, and it will simplify the internal code, since the default warn handler will no longer vary by backend.

(The Node backend does currently show warnings by default, but only if NODE_ENV is explicitly set to development, and I think it’s too much to hope that this will be common. We could try to flip this around – show warnings by default unless NODE_ENV is set to production – but I don’t think this is worth it. Many bots and tool backends will want to see warnings in “production” as well anyways.)