Common error handler for most of 4xx errors

In this case, errors differ only in message and code, so it seems to be
wise to put common code in common function.

Change-Id: Ie18e82a078a301393f53e098527e8a3d7494f0d2