Refactor error constants and messages for query-api module

Resolve various Sonar issues introduced in my preceding commits