Exception: Genius::Errors::PageNotFound

Inherits:
GeniusExceptionSuperClass show all
Defined in:
lib/genius/api/errors.rb

Overview

A PageNotFound object handles an exception where response payload is invalid and Genius itself or its related service returns not found.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg: 'Page not found. Try again with another response', exception_type: 'page_not_found') ⇒ void

Initializes a page-not-found error.

Parameters:

  • msg (String) (defaults to: 'Page not found. Try again with another response')

    Error message.

  • exception_type (String) (defaults to: 'page_not_found')

    Error type identifier.



107
108
109
110
111
# File 'lib/genius/api/errors.rb', line 107

def initialize(msg: 'Page not found. Try again with another response', exception_type: 'page_not_found')
  @msg = msg
  @exception_type = exception_type
  super(msg)
end

Instance Attribute Details

#exception_typeObject (readonly)

Returns the value of attribute exception_type.



100
101
102
# File 'lib/genius/api/errors.rb', line 100

def exception_type
  @exception_type
end

#msgObject (readonly)

Returns the value of attribute msg.



100
101
102
# File 'lib/genius/api/errors.rb', line 100

def msg
  @msg
end

Class Method Details

.page_not_found?(html) ⇒ Boolean

Checks if the HTML response indicates a page-not-found error.

Parameters:

  • html (Object)

    Parsed HTML document.

Returns:

  • (Boolean)


117
118
119
# File 'lib/genius/api/errors.rb', line 117

def self.page_not_found?(html)
  html.text.include?('Page not found')
end