Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fix eq, typeof


Code Block
languagejavascript
themeConfluencelanguagejavascript
        cloud_url = "https://#{meta:host()}/sky/cloud/";
       
        cloud = function(eci, mod, func, params) {
            response = http:get("#{cloud_url}#{mod}/#{func}", (params || {}).put(["_eci"], eci));


            status = response{"status_code"};


            error_info = {
                "error": "sky cloud request was unsuccesful.",
                "httpStatus": {
                    "code": status,
                    "message": response{"status_line"}
                }
            };


            response_content = response{"content"}.decode();
            response_error = (response_content.typeof() eq== "hashMap" && response_content{"error"}) => response_content{"error"} | 0;
            response_error_str = (response_content.typeof() eq== "hashMap" && response_content{"error_str"}) => response_content{"error_str"} | 0;
            error = error_info.put({"skyCloudError": response_error, "skyCloudErrorMsg": response_error_str, "skyCloudReturnValue": response_content});
            is_bad_response = (response_content.isnull() || response_content eq== "null" || response_error || response_error_str);


            // if HTTP status was OK & the response was not null and there were no errors...
            (status eq== "200" && not is_bad_response) => response_content | error
        };