Log API errors in JavaScript to console if in debug mode

This could come in handy as it's quite bearable for firm users to
attach debug=true to the URI and have a look at the consoles
of their browsers. We need this inn case errors occur for which
we don't have a specific message.

Change-Id: I49d0de17d3bcbaa94fb6227b7086c8c8b0d39119
Merge "Log API errors in JavaScript to console if in debug mode"