Sha256: 360c469e8025b372703c6d63ca27c99cfe924fc74982884b86bd632b14af87f2

Contents?: true

Size: 411 Bytes

Versions: 8

Compression:

Stored size: 411 Bytes

Contents

# frozen_string_literal: true

class Pagy

  # generic variable error
  class VariableError < ArgumentError
    attr_reader :pagy

    def initialize(pagy)
      super
      @pagy = pagy
    end

    def variable
      message =~ /expected :(\w+)/
      Regexp.last_match(1)&.to_sym
    end

    def value = pagy.vars[variable]
  end

  # specific overflow error
  class OverflowError < VariableError; end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pagy-4.7.1 lib/pagy/exceptions.rb
pagy-4.7.0 lib/pagy/exceptions.rb
pagy-4.6.0 lib/pagy/exceptions.rb
pagy-4.5.1 lib/pagy/exceptions.rb
pagy-4.5.0 lib/pagy/exceptions.rb
pagy-4.4.0 lib/pagy/exceptions.rb
pagy-4.3.0 lib/pagy/exceptions.rb
pagy-4.2.0 lib/pagy/exceptions.rb