Exception: Fluent::BigQuery::Error
Abstract
- Inherits:
-
StandardError
- Object
- StandardError
- Fluent::BigQuery::Error
show all
- Defined in:
- lib/fluent/plugin/bigquery/errors.rb
Overview
Constant Summary
collapse
- RETRYABLE_ERROR_REASON =
%w(backendError internalError rateLimitExceeded tableUnavailable).freeze
- RETRYABLE_STATUS_CODE =
[500, 503]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(message, origin = nil) ⇒ Error
Returns a new instance of Error.
45
46
47
48
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 45
def initialize(message, origin = nil)
@origin = origin
super(message || origin.message)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 50
def method_missing(name, *args)
if @origin
@origin.send(name, *args)
else
super
end
end
|
Instance Attribute Details
#origin ⇒ Object
Returns the value of attribute origin.
43
44
45
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 43
def origin
@origin
end
|
Class Method Details
.inherited(subclass) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 34
def inherited(subclass)
subclass.class_eval do
class << self
public :new
end
end
end
|
.retryable_error?(google_api_error) ⇒ Boolean
20
21
22
23
24
25
26
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 20
def retryable_error?(google_api_error)
e = google_api_error
reason = e.respond_to?(:reason) ? e.reason : nil
retryable_error_reason?(reason) ||
(e.is_a?(Google::Apis::ServerError) && RETRYABLE_STATUS_CODE.include?(e.status_code))
end
|
.retryable_error_reason?(reason) ⇒ Boolean
28
29
30
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 28
def retryable_error_reason?(reason)
RETRYABLE_ERROR_REASON.include?(reason)
end
|
.wrap(google_api_error, message = nil, force_unretryable: false) ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 9
def wrap(google_api_error, message = nil, force_unretryable: false)
e = google_api_error
return UnRetryableError.new(message, e) if force_unretryable
if retryable_error?(e)
RetryableError.new(message, e)
else
UnRetryableError.new(message, e)
end
end
|
Instance Method Details
#body ⇒ Object
66
67
68
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 66
def body
@origin && @origin.respond_to?(:body) ? @origin.body : nil
end
|
#reason ⇒ Object
58
59
60
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 58
def reason
@origin && @origin.respond_to?(:reason) ? @origin.reason : nil
end
|
#retryable? ⇒ Boolean
70
71
72
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 70
def retryable?
false
end
|
#status_code ⇒ Object
62
63
64
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 62
def status_code
@origin && @origin.respond_to?(:status_code) ? @origin.status_code : nil
end
|