Sha256: c371c4a4d4ee08c6fe27c8f4d2f17f72aa4b85023fa454f9d4674e99bb7cc599

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

module BibTeX
  class BibTeXError < StandardError
    attr_reader :original

    def initialize(message = nil, original = $ERROR_INFO)
      super(message)
      @original = original
    end
  end

  class ParseError < BibTeXError; end
  class ArgumentError < BibTeXError; end

  #
  # Represents a lexical or syntactical error.
  #
  class Error < Element
    attr_reader :trace

    def initialize(trace = [])
      @trace = trace
    end

    def trace=(trace)
      raise(ArgumentError, "BibTeX::Error trace must be of type Array; was: #{trace.class.name}.") unless trace.is_a?(Array)

      @trace = trace
    end

    def content
      @trace.map { |e| e[1] }.join
    end

    # Called when the element was added to a bibliography.
    def added_to_bibliography(bibliography)
      super(bibliography)
      bibliography.errors << self
      self
    end

    # Called when the element was removed from a bibliography.
    def removed_from_bibliography(bibliography)
      super(bibliography)
      bibliography.errors.delete(self)
      self
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
bibtex-ruby-6.1.0 lib/bibtex/error.rb
bibtex-ruby-6.0.0 lib/bibtex/error.rb
bibtex-ruby-5.1.6 lib/bibtex/error.rb
bibtex-ruby-5.1.5 lib/bibtex/error.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/bibtex-ruby-5.1.4/lib/bibtex/error.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/bibtex-ruby-5.1.4/lib/bibtex/error.rb
bibtex-ruby-5.1.4 lib/bibtex/error.rb
bibtex-ruby-5.1.3 lib/bibtex/error.rb
bibtex-ruby-5.1.2 lib/bibtex/error.rb
bibtex-ruby-5.1.1 lib/bibtex/error.rb
bibtex-ruby-5.1.0 lib/bibtex/error.rb
bibtex-ruby-5.0.1 lib/bibtex/error.rb
bibtex-ruby-5.0.0 lib/bibtex/error.rb