lib/jss/api_object.rb in ruby-jss-1.4.1 vs lib/jss/api_object.rb in ruby-jss-1.5.1

- old
+ new

@@ -847,15 +847,11 @@ else raise ArgumentError, 'Missing searchterm or fetch key' end - begin - return new fetch_rsrc: fetch_rsrc, api: api - rescue RestClient::NotFound - raise JSS::NoSuchItemError, "No #{self::RSRC_OBJECT_KEY} found #{err_detail}" unless fetch_rsrc - end + new fetch_rsrc: fetch_rsrc, api: api end # fetch # Fetch the mostly- or fully-raw JSON or XML data for an object of this # subclass. # @@ -893,12 +889,10 @@ rsrc = "#{self::RSRC_BASE}/id/#{id}" data = api.get_rsrc rsrc, format, raw_json: as_string return data if format == :json || as_string REXML::Document.new(data) - rescue RestClient::NotFound - raise JSS::NoSuchItemError, "No #{self} with id #{id}" end # PUT some raw XML to the API for a given id in this subclass. # # WARNING: You must create or acquire the XML to be sent, and no validation @@ -923,12 +917,10 @@ # def self.put_raw(id, xml, api: JSS.api) validate_not_metaclass(self) rsrc = "#{self::RSRC_BASE}/id/#{id}" REXML::Document.new(api.put_rsrc rsrc, xml.to_s) - rescue RestClient::NotFound - raise JSS::NoSuchItemError, "No #{self} with id #{id}" end # POST some raw XML to the API for a given id in this subclass. # # WARNING: You must create or acquire the XML to be sent, and no validation @@ -1221,19 +1213,13 @@ # # @return [void] # def delete return unless @in_jss - begin - @api.delete_rsrc @rest_rsrc - rescue RestClient::NotFound, RestClient::ResourceNotFound - # over slow connections (?) or more likely - # split-tunnel VPN connections, sometimes the thing gets deleted - # the call gets a 404 anyway - nil - end + @api.delete_rsrc @rest_rsrc + @rest_rsrc = "#{self.class::RSRC_BASE}/name/#{CGI.escape @name.to_s}" @id = nil @in_jss = false @need_to_update = false @@ -1431,11 +1417,9 @@ # otherwise @api.get_rsrc(rsrc) end raw_json[args[:rsrc_object_key]] - rescue RestClient::ResourceNotFound - raise NoSuchItemError, "No #{self.class::RSRC_OBJECT_KEY} found matching resource #{rsrc}" end # Start examining the @init_data recieved from the API # # @return [void]