refactor error/warning reporting

Refactor error/warning reporting to prepare making it configurable.

review by @gkossakowski (on hangout?)