[API]: Debug fixes

Don't spit out whole exception in non-debug mode
Do log queries in debug mode

Change-Id: Ibaa42c7f9af0d3ae9d59e50cadd7c4a10af32247
Merge "[API]: Debug fixes"