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

Warn if user agent isn’t specified?

lucaswerkmeister opened this issue · comments

The Python mwapi library warns if no user agent is specified, before falling back to a default user agent. In m3api, we currently fall back to a default user agent without producing any warning. Should we add a warning?

And if yes, how should that warning work? mwapi warns using the standard Python logging module; the closest equivalent in JavaScript is console.warn(), but is it acceptable to write to that in a library?

If we want to add such a warning, we should probably do it in some pre-1.0.0 release, and then revisit the decision before the 1.0.0 release, checking if anybody complained about the warning.

With the new warnings support in #8, it should be clear how the warning is emitted. (I intentionally documented the warn() handler as being called with “a subclass of Error, such as ApiWarnings”, so that we’re also allowed to introduce a separate class like DefaultUserAgentWarning and call warn() with that.) But let’s wait until after the initial release with warnings support.