handle custom return code and content type