Allow hooks for mapping server codes to errors

This also helps handle sane behavior if a new error code is introduced,
or allow user-defined logging when a specific error code is received.

Change-Id: I6530aa7efceec2b7c26ddc14edab581dd48f3f6e
Reviewed-on: http://review.couchbase.org/29929
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>