Hello community,

here is the log from the commit of package rubygem-cfa for openSUSE:Factory 
checked in at 2018-11-10 16:50:05
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-cfa (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-cfa.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-cfa"

Sat Nov 10 16:50:05 2018 rev:10 rq:647329 version:0.7.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-cfa/rubygem-cfa.changes  2018-04-26 
13:31:38.174140329 +0200
+++ /work/SRC/openSUSE:Factory/.rubygem-cfa.new/rubygem-cfa.changes     
2018-11-10 16:50:39.908395407 +0100
@@ -1,0 +2,8 @@
+Thu Nov  8 12:51:22 UTC 2018 - jreidin...@suse.com
+
+- Improve even more error reporting now with specialized exceptions
+  that holds all details for better user reports
+  (needed for bsc#1113996)
+- 0.7.0
+
+-------------------------------------------------------------------

Old:
----
  cfa-0.6.4.gem

New:
----
  cfa-0.7.0.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-cfa.spec ++++++
--- /var/tmp/diff_new_pack.AWM6R1/_old  2018-11-10 16:50:40.308394901 +0100
+++ /var/tmp/diff_new_pack.AWM6R1/_new  2018-11-10 16:50:40.308394901 +0100
@@ -12,12 +12,12 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
 Name:           rubygem-cfa
-Version:        0.6.4
+Version:        0.7.0
 Release:        0
 %define mod_name cfa
 %define mod_full_name %{mod_name}-%{version}

++++++ cfa-0.6.4.gem -> cfa-0.7.0.gem ++++++
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/cfa/augeas_parser/keys_cache.rb 
new/lib/cfa/augeas_parser/keys_cache.rb
--- old/lib/cfa/augeas_parser/keys_cache.rb     2018-04-25 09:53:05.000000000 
+0200
+++ new/lib/cfa/augeas_parser/keys_cache.rb     2018-11-08 15:18:36.000000000 
+0100
@@ -22,6 +22,7 @@
       loop do
         matches = aug.match(search_path)
         break if matches.empty?
+
         assign_matches(matches, @cache)
 
         search_path += "/*"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/cfa/augeas_parser/writer.rb 
new/lib/cfa/augeas_parser/writer.rb
--- old/lib/cfa/augeas_parser/writer.rb 2018-04-25 09:53:05.000000000 +0200
+++ new/lib/cfa/augeas_parser/writer.rb 2018-11-08 15:18:36.000000000 +0100
@@ -139,6 +139,7 @@
       # the entries preceding this entry
       def preceding_entries
         return [] if index.zero? # first entry
+
         tree.all_data[0..(index - 1)]
       end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/cfa/augeas_parser.rb new/lib/cfa/augeas_parser.rb
--- old/lib/cfa/augeas_parser.rb        2018-04-25 09:53:05.000000000 +0200
+++ new/lib/cfa/augeas_parser.rb        2018-11-08 15:18:36.000000000 +0100
@@ -35,6 +35,66 @@
   class AugeasElement < Hash
   end
 
+  # Error that is raised when augeas fail for some reason.
+  # Base class for more specialized exceptions.
+  class AugeasError < RuntimeError
+  end
+
+  # Error in augeas itself like broken lens
+  class AugeasInternalError < AugeasError
+    attr_reader :details
+    attr_reader :aug_message
+
+    def initialize(message, details)
+      @aug_message = message
+      @details = details
+
+      super("Augeas error: #{message}. Details: #{details}.")
+    end
+  end
+
+  # Parsing error
+  class AugeasParsingError < AugeasError
+    attr_reader :aug_message
+    attr_reader :file
+    attr_reader :line
+    attr_reader :character
+    attr_reader :lens
+    attr_reader :file_content
+
+    def initialize(params)
+      @aug_message = params[:message]
+      @file = params[:file]
+      @line = params[:line]
+      @char = params[:char]
+      @lens = params[:lens]
+      @file_content = params[:file_content]
+
+      super("Augeas parsing error: #{@aug_message}" \
+        " at #{@file}:#{@line}:#{@char}, lens #{@lens}"
+      )
+    end
+  end
+
+  # Serializing error
+  class AugeasSerializingError < AugeasError
+    attr_reader :aug_message
+    attr_reader :file
+    attr_reader :lens
+    attr_reader :aug_tree
+
+    def initialize(params)
+      @aug_message = params[:message]
+      @file = params[:file]
+      @lens = params[:lens]
+      @aug_tree = params[:aug_tree]
+
+      super("Augeas serializing error: #{@aug_message}" \
+        " for #{@file} with lens #{@lens}"
+      )
+    end
+  end
+
   # Represents list of same config options in augeas.
   # For example comments are often stored in collections.
   class AugeasCollection
@@ -168,6 +228,7 @@
       id = 1
       loop do
         return id.to_s unless ids.include?(id.to_s)
+
         id += 1
       end
     end
@@ -180,6 +241,7 @@
     # @param [String, Matcher] matcher
     def delete(matcher)
       return if matcher.nil?
+
       unless matcher.is_a?(CFA::Matcher)
         matcher = CFA::Matcher.new(key: matcher)
       end
@@ -236,6 +298,7 @@
 
     def ==(other)
       return false if self.class != other.class
+
       other_data = other.data # do not compute again
       data.each_with_index do |entry, index|
         other_entry = other_data[index]
@@ -329,7 +392,7 @@
       root = load_path = nil
       Augeas.open(root, load_path, Augeas::NO_MODL_AUTOLOAD) do |aug|
         aug.set("/input", raw_string)
-        report_error(aug, "parsing", file_name) \
+        report_error(aug, :parsing, file_name, raw_string) \
           unless aug.text_store(@lens, "/input", "/store")
 
         return AugeasReader.read(aug, "/store")
@@ -349,7 +412,7 @@
         AugeasWriter.new(aug).write("/store", data)
 
         res = aug.text_retrieve(@lens, "/input", "/store", "/output")
-        report_error(aug, "serializing", file_name) unless res
+        report_error(aug, :serializing, file_name, data) unless res
 
         return aug.get("/output")
       end
@@ -364,19 +427,38 @@
   private
 
     # @param aug [::Augeas]
-    # @param activity ["parsing", "serializing"] for better error messages
+    # @param activity [:parsing, :serializing] for better error messages
     # @param file_name [String,nil] a file name
-    def report_error(aug, activity, file_name)
-      error = aug.error
-      # zero is no error, so problem in lense
-      if error[:code].nonzero?
-        raise "Augeas error: #{error[:message]}. Details: #{error[:details]}."
-      end
+    # @param data [AugeasTree, String] used data so augeas tree for
+    #   serializing or file content for parsing
+    def report_error(aug, activity, file_name, data = nil)
+      report_internal_error!(aug)
 
       file_name ||= "(unknown file)"
-      raise format("Augeas #{activity} error: %<message>s" \
-                   " at #{file_name}:%<line>s:%<char>s, lens %<lens>s",
-        aug_get_error(aug))
+      args = aug_get_error(aug)
+      args[:file] = file_name
+      report_activity_error!(args, activity, data)
+    end
+
+    def report_internal_error!(aug)
+      error = aug.error
+      # zero is no error, so there's a problem in the lens
+      return if error[:code].zero?
+
+      raise AugeasInternalError.new(error[:message], error[:details])
+    end
+
+    def report_activity_error!(args, activity, data)
+      case activity
+      when :parsing
+        args[:file_content] = data
+        raise AugeasParsingError, args
+      when :serializing
+        args[:aug_tree] = data
+        raise AugeasSerializingError, args
+      else
+        raise ArgumentError, "invalid activity #{activity.inspect}"
+      end
     end
 
     def aug_get_error(aug)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/cfa/matcher.rb new/lib/cfa/matcher.rb
--- old/lib/cfa/matcher.rb      2018-04-25 09:53:05.000000000 +0200
+++ new/lib/cfa/matcher.rb      2018-11-08 15:18:36.000000000 +0100
@@ -43,6 +43,7 @@
         return false unless collection_match?(element, collection)
         return false unless value_match?(element, value_matcher)
         return false unless !block || yield(element[:key], element[:value])
+
         return true
       end
     end
@@ -71,6 +72,7 @@
       when nil then true
       when Regexp
         return false unless element[:value].is_a?(String)
+
         matcher =~ element[:value]
       else
         matcher == element[:value]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2018-04-25 09:54:45.000000000 +0200
+++ new/metadata        2018-11-08 15:18:47.000000000 +0100
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: cfa
 version: !ruby/object:Gem::Version
-  version: 0.6.4
+  version: 0.7.0
 platform: ruby
 authors:
 - Josef Reidinger
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2018-04-25 00:00:00.000000000 Z
+date: 2018-11-08 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: ruby-augeas


Reply via email to