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") ⇒ String (frozen)

Parameters:

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

    Exception message.

  • exception_type (String (frozen)) (defaults to: "page_not_found")

    Exception type.



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

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.



95
96
97
# File 'lib/genius/api/errors.rb', line 95

def exception_type
  @exception_type
end

#msgObject (readonly)

Returns the value of attribute msg.



95
96
97
# File 'lib/genius/api/errors.rb', line 95

def msg
  @msg
end

Class Method Details

.page_not_found?(html) ⇒ TrueClass, FalseClass

Genius::Errors::PageNotFound.page_not_found? -> true or false

PageNotFound.page_not_found? method is used to be a predicate for handling 404 error.

Parameters:

Returns:

  • (TrueClass)

    if genius page is not found

  • (FalseClass)

    if genius page is found



114
115
116
# File 'lib/genius/api/errors.rb', line 114

def self.page_not_found?(html)
  html.text.match?(/Page not found/)
end