Uploaded image for project: 'OpenShift Java Client'
  1. OpenShift Java Client
  2. OSJC-39

openshift-java-client: cannot get json response from exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.0.3
    • None
    • None
    • None

      With the change in JBIDE-13763, which implemented human readable exceptions that tell the user to what server the exception was occurring, we lost the ability to get the json from the exception. This is not ideal since the json contains the exact error message and error code from the server.
      Before JBIDE-13763 OpenShiftEndpointException reported the server returned json as object when one called OpenShiftEndpointException#getRestResponse. OpenShiftEndpointException internally by getting the message from the HttpClientException it is wrapping:

      RestService#request
      		} catch (HttpClientException e) {
      			throw new OpenShiftEndpointException(
      					url.toString(), e, e.getMessage(),
      					"Could not request {0}: {1}", url.toString(), getResponseMessage(e));
      

      before JBIDE-13763:

      HttpClientException.getMessage()
      {
         "data":null,
         "errors":{
      
         },
         "messages":[
            {
               "exit_code":128,
               "field":null,
               "severity":"error",
               "text":"Domain contains applications. Delete applications first or set force to true."
            }
         ],
         "status":"bad_request",
         "supported_api_versions":[
            1.0,
            1.1,
            1.2,
            1.3
         ],
         "type":null,
         "version":"1.0"
      }
      

      after JBIDE-13763:

      HttpClientException.getMessage()
      Connection to https://stg.openshift.redhat.com/broker/rest/domains/1363341069128, {
         "data":null,
         "errors":{
      
         },
         "messages":[
            {
               "exit_code":128,
               "field":null,
               "severity":"error",
               "text":"Domain contains applications. Delete applications first or set force to true."
            }
         ],
         "status":"bad_request",
         "supported_api_versions":[
            1.0,
            1.1,
            1.2,
            1.3
         ],
         "type":null,
         "version":"1.0"
      }
      

      When the user asks the OpenShiftEndpointException for the json from the server it would call OpenShiftEndpointException#getRestResponse() which would parse the message from json and return a RestResponse object.

            adietish@redhat.com André Dietisheim
            adietish@redhat.com André Dietisheim
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: