Sha256: cf1c2fa5e9d81b0175f223b6810e1964393a13de8cea2a9f29c4bab41609ba71

Contents?: true

Size: 1.26 KB

Versions: 12

Compression:

Stored size: 1.26 KB

Contents

module ThreeScaleToolbox
  # Generic error. Superclass for all specific errors.
  class Error < ::StandardError
    def code
      'E_3SCALE'
    end

    def kind
      self.class
    end

    def stacktrace
      # For managed errors, stacktrace should not be necessary
      nil
    end
  end

  class InvalidUrlError < Error
    def code
      'E_INVALID_URL'
    end
  end

  class ActiveDocsNotFoundError < Error
    attr_reader :id

    def initialize(id)
      super("ActiveDocs with ID #{id} not found")
    end

    def code
      'E_ACTIVEDOCS_NOT_FOUND'
    end
  end

  class ThreeScaleApiError < Error
    attr_reader :apierrors

    def initialize(msg = '', apierrors = {})
      @apierrors = apierrors
      super(msg)
    end

    def message
      "#{super}. Errors: #{apierrors}"
    end

    def code
      'E_3SCALE_API'
    end
  end

  class InvalidIdError < Error
    def code
      'E_INVALID_ID'
    end
  end

  class UnexpectedError < ::StandardError
    attr_reader :unexpectederror

    def initialize(err)
      @unexpectederror = err
    end

    def message
      unexpectederror.message
    end

    def kind
      unexpectederror.class
    end

    def code
      'E_UNKNOWN'
    end

    def stacktrace
      unexpectederror.backtrace
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
3scale_toolbox-1.0.1 lib/3scale_toolbox/error.rb
3scale_toolbox-1.0.0 lib/3scale_toolbox/error.rb
3scale_toolbox-0.20.0 lib/3scale_toolbox/error.rb
3scale_toolbox-0.19.3 lib/3scale_toolbox/error.rb
3scale_toolbox-0.19.2 lib/3scale_toolbox/error.rb
3scale_toolbox-0.19.1 lib/3scale_toolbox/error.rb
3scale_toolbox-0.19.0 lib/3scale_toolbox/error.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/error.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/error.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/error.rb
3scale_toolbox-0.17.1 lib/3scale_toolbox/error.rb
3scale_toolbox-0.17.0 lib/3scale_toolbox/error.rb