better error response handling with specific exceptions for various codes returned from API