Return-Path: X-Original-To: apmail-incubator-ambari-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-ambari-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EFD45102D4 for ; Tue, 17 Sep 2013 20:08:38 +0000 (UTC) Received: (qmail 66766 invoked by uid 500); 17 Sep 2013 20:08:03 -0000 Delivered-To: apmail-incubator-ambari-dev-archive@incubator.apache.org Received: (qmail 66673 invoked by uid 500); 17 Sep 2013 20:07:59 -0000 Mailing-List: contact ambari-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@incubator.apache.org Delivered-To: mailing list ambari-dev@incubator.apache.org Received: (qmail 66549 invoked by uid 99); 17 Sep 2013 20:07:57 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Sep 2013 20:07:57 +0000 Date: Tue, 17 Sep 2013 20:07:57 +0000 (UTC) From: "Mahadev konar (JIRA)" To: ambari-dev@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Reopened] (AMBARI-3244) Ambari Client improve errors handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AMBARI-3244?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Mahadev konar reopened AMBARI-3244: ----------------------------------- > Ambari Client improve errors handling > ------------------------------------- > > Key: AMBARI-3244 > URL: https://issues.apache.org/jira/browse/AMBARI-3244 > Project: Ambari > Issue Type: Task > Reporter: Andrew Onischuk > Assignee: Andrew Onischuk > Priority: Critical > Fix For: 1.4.1 > > Attachments: AMBARI-3244_2.patch, AMBARI-3244.patch > > > 1. Add a server error response to the getters and creators > From the user's side error handling look's like this: > {code} > try: > // will fail somewhere during trying to create a host model with corrupt > // response > host = client.get_host('not existant host') > except Exception, ex: > print "Unknown termination reason!" > return > {code} > Should be: > {code} > host, err_resp = client.get_host('not existant host') > if err_resp: > print "Error happened, terminating with error code" % (err_resp.status) > print "Reason: %s" % (err_resp.message) > return > {code} > 2. Some error messages are missed. The problem is that the way we decide, whether error response is decodable can't be based on the error code > E.g. 404 can be json as well as html > {code} > component = client.get_components('HDP-1.0.0', 'JOBTRACKER') > {code} > {code} > { > "status" : 404, > "message" : "The requested resource doesn't exist: Stack data, stackName=HDP, stackVersion=HDP-1.0.0" > } > {code} > 3. Encapsulate from user messing with return codes, to find out if everything was fine > Is > {code} > resp = cluster.delete_host('bad_host') > > if resp.status != 200 and resp.status != 201: > print "Terminating on error" > return > {code} > Should be: > {code} > resp = cluster.delete_host('bad_host') > > if resp.is_error(): > print "Terminating on error" > return > {code} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira