Module: BigQuery::Client::Errors

Included in:
BigQuery::Client
Defined in:
lib/big_query/client/errors.rb

Instance Method Summary collapse

Instance Method Details

#handle_error(response) ⇒ Object

handles the error and raises an understandable error

Parameters:

  • response (Hash)

    parsed json response

Raises:



16
17
18
19
20
21
22
23
24
# File 'lib/big_query/client/errors.rb', line 16

def handle_error(response)
  error = response['error']
  case error['code']
  when 404
    fail BigQuery::Errors::NotFound, error['message']
  else
    fail BigQuery::Errors::BigQueryError, error['message']
  end
end

#is_error?(response) ⇒ Boolean

Defines whenever the response is an error or not

Parameters:

  • response (Hash)

    parsed json response

Returns:

  • (Boolean)


8
9
10
# File 'lib/big_query/client/errors.rb', line 8

def is_error?(response)
  !response["error"].nil?
end