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_INSERT_ERRORS_REASON =
%w(timeout backendError internalError rateLimitExceeded).freeze
- RETRYABLE_STATUS_CODE =
[500, 502, 503, 504]
- REGION_NOT_WRITABLE_MESSAGE =
-"is not writable in the region"
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.
55
56
57
58
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 55
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
60
61
62
63
64
65
66
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 60
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.
53
54
55
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 53
def origin
@origin
end
|
Class Method Details
.inherited(subclass) ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 44
def inherited(subclass)
subclass.class_eval do
class << self
public :new
end
end
end
|
.retryable_error?(e) ⇒ Boolean
22
23
24
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 22
def retryable_error?(e)
retryable_server_error?(e) || retryable_region_not_writable?(e)
end
|
.retryable_error_reason?(reason) ⇒ Boolean
30
31
32
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 30
def retryable_error_reason?(reason)
RETRYABLE_ERROR_REASON.include?(reason)
end
|
.retryable_insert_errors_reason?(reason) ⇒ Boolean
34
35
36
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 34
def retryable_insert_errors_reason?(reason)
RETRYABLE_INSERT_ERRORS_REASON.include?(reason)
end
|
.retryable_region_not_writable?(e) ⇒ Boolean
38
39
40
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 38
def retryable_region_not_writable?(e)
e.is_a?(Google::Apis::ClientError) && e.status_code == 400 && e.message.include?(REGION_NOT_WRITABLE_MESSAGE)
end
|
.retryable_server_error?(e) ⇒ Boolean
26
27
28
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 26
def retryable_server_error?(e)
e.is_a?(Google::Apis::ServerError) && RETRYABLE_STATUS_CODE.include?(e.status_code)
end
|
.wrap(e, message = nil) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 13
def wrap(e, message = nil)
if retryable_error?(e)
RetryableError.new(message, e)
else
UnRetryableError.new(message, e)
end
end
|
Instance Method Details
#body ⇒ Object
76
77
78
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 76
def body
@origin && @origin.respond_to?(:body) ? @origin.body : nil
end
|
#reason ⇒ Object
68
69
70
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 68
def reason
@origin && @origin.respond_to?(:reason) ? @origin.reason : nil
end
|
#retryable? ⇒ Boolean
80
81
82
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 80
def retryable?
false
end
|
#status_code ⇒ Object
72
73
74
|
# File 'lib/fluent/plugin/bigquery/errors.rb', line 72
def status_code
@origin && @origin.respond_to?(:status_code) ? @origin.status_code : nil
end
|