Exception: Blupee::API::APIError
- Inherits:
- 
      BlupeeError
      
        - Object
- StandardError
- BlupeeError
- Blupee::API::APIError
 
- Defined in:
- lib/blupee/errors.rb
Overview
Facebook responded with an error to an API request. If the exception contains a nil http_status, then the error was detected before making a call to Facebook. (e.g. missing access token)
Direct Known Subclasses
BadBlupeeAPIResponse, ClientError, OAuthTokenRequestError, ServerError
Instance Attribute Summary collapse
- 
  
    
      #error_code  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute error_code. 
- 
  
    
      #error_debug  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute error_debug. 
- 
  
    
      #error_message  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute error_message. 
- 
  
    
      #error_rev  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute error_rev. 
- 
  
    
      #error_subcode  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute error_subcode. 
- 
  
    
      #error_trace_id  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute error_trace_id. 
- 
  
    
      #error_type  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute error_type. 
- 
  
    
      #error_user_msg  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute error_user_msg. 
- 
  
    
      #error_user_title  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute error_user_title. 
- 
  
    
      #http_status  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute http_status. 
- 
  
    
      #response_body  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute response_body. 
Instance Method Summary collapse
- 
  
    
      #initialize(http_status, response_body, error_info = nil)  ⇒ Object 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Create a new API Error. 
Constructor Details
#initialize(http_status, response_body, error_info = nil) ⇒ Object
Create a new API Error
| 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | # File 'lib/blupee/errors.rb', line 40 def initialize(http_status, response_body, error_info = nil) if response_body self.response_body = response_body.strip else self.response_body = '' end self.http_status = http_status if error_info && error_info.is_a?(String) = error_info else unless error_info begin error_info = JSON.parse(response_body)['error'] if response_body rescue end error_info ||= {} end self.error_type = error_info["type"] self. = error_info["message"] self.error_trace_id = error_info["x-blu-trace-id"] self.error_debug = error_info["x-blu-debug"] self.error_rev = error_info["x-blu-rev"] error_array = [] %w(type code error_subcode message error_user_title error_user_msg x-blu-trace-id).each do |key| error_array << "#{key}: #{error_info[key]}" if error_info[key] end if error_array.empty? = self.response_body else = error_array.join(', ') end end += " [HTTP #{http_status}]" if http_status super() end | 
Instance Attribute Details
#error_code ⇒ Object
Returns the value of attribute error_code.
| 16 17 18 | # File 'lib/blupee/errors.rb', line 16 def error_code @error_code end | 
#error_debug ⇒ Object
Returns the value of attribute error_debug.
| 16 17 18 | # File 'lib/blupee/errors.rb', line 16 def error_debug @error_debug end | 
#error_message ⇒ Object
Returns the value of attribute error_message.
| 16 17 18 | # File 'lib/blupee/errors.rb', line 16 def @error_message end | 
#error_rev ⇒ Object
Returns the value of attribute error_rev.
| 16 17 18 | # File 'lib/blupee/errors.rb', line 16 def error_rev @error_rev end | 
#error_subcode ⇒ Object
Returns the value of attribute error_subcode.
| 16 17 18 | # File 'lib/blupee/errors.rb', line 16 def error_subcode @error_subcode end | 
#error_trace_id ⇒ Object
Returns the value of attribute error_trace_id.
| 16 17 18 | # File 'lib/blupee/errors.rb', line 16 def error_trace_id @error_trace_id end | 
#error_type ⇒ Object
Returns the value of attribute error_type.
| 16 17 18 | # File 'lib/blupee/errors.rb', line 16 def error_type @error_type end | 
#error_user_msg ⇒ Object
Returns the value of attribute error_user_msg.
| 16 17 18 | # File 'lib/blupee/errors.rb', line 16 def error_user_msg @error_user_msg end | 
#error_user_title ⇒ Object
Returns the value of attribute error_user_title.
| 16 17 18 | # File 'lib/blupee/errors.rb', line 16 def error_user_title @error_user_title end | 
#http_status ⇒ Object
Returns the value of attribute http_status.
| 16 17 18 | # File 'lib/blupee/errors.rb', line 16 def http_status @http_status end | 
#response_body ⇒ Object
Returns the value of attribute response_body.
| 16 17 18 | # File 'lib/blupee/errors.rb', line 16 def response_body @response_body end |