REST API: Return different errors.

Return different errors identifiers and messages in order to identify
the nature of the errors.