Change returned error codes pattern.

 Thanks to jsynacek for inspiration.