error handling, set http response codes