reworked API exception handling and error response