Fix error handling

In several places errors were written directly to the stdout.
This change correctly reports them with exception.

Change-Id: I29395cedcfcef5f820b2f08c7f003e2a67cfb282
Reviewed-on: https://pirx.atteo.com/gerrit/328
Tested-by: Mr. Jenkins
Reviewed-by: Sławek Piotrowski <sentinel@atteo.com>
Fix generate schema test

Change-Id: I8540011c1ba0b1186c1960454cc802b21e88812e
Reviewed-on: https://pirx.atteo.com/gerrit/353
Tested-by: Mr. Jenkins
Reviewed-by: Sławek Piotrowski <sentinel@atteo.com>