def __error_middleware(self, res, res_json):
if(res.status_code in [<NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>]):<EOL><INDENT>err_dict = res_json.get('<STR_LIT:error>', {})<EOL>raise UpCloudAPIError(error_code=err_dict.get('<STR_LIT>'),<EOL>error_message=err_dict.get('<STR_LIT>'))<EOL><DEDENT>return res_json<EOL>
Middleware that raises an exception when HTTP statuscode is an error code.