fix: properly set http response code on error response