Skip to content

Commit 4184b3c

Browse files
authored
Expand error documentation for query protocol (#3205)
1 parent d06f42d commit 4184b3c

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/error_list.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def initialize(options)
2525
members: members,
2626
data_type: "#{@module_name}::Types::#{name}",
2727
retryable: !!shape['retryable'],
28-
throttling: throttling?(shape)
28+
throttling: throttling?(shape),
29+
custom_error_class: custom_error_class(shape)
2930
)
3031
end
3132
es
@@ -45,6 +46,11 @@ def throttling?(shape)
4546
shape['retryable'] && shape['retryable'].kind_of?(Hash) && shape['retryable']['throttling']
4647
end
4748

49+
def custom_error_class(shape)
50+
return unless (custom_error_name = shape.dig('error', 'code'))
51+
52+
custom_error_name
53+
end
4854

4955
class Error
5056

@@ -54,6 +60,7 @@ def initialize(options)
5460
@members = options[:members]
5561
@retryable = options[:retryable]
5662
@throttling = options[:throttling]
63+
@custom_error_class = options[:custom_error_class]
5764
end
5865

5966
# @return [String]
@@ -71,6 +78,14 @@ def initialize(options)
7178
# @return [Boolean]
7279
attr_reader :throttling
7380

81+
# @return [String, nil]
82+
attr_reader :custom_error_class
83+
84+
# Covers dynamically created errors by query protocol
85+
def custom_error_class?
86+
!@custom_error_class.nil? && @name != @custom_error_class
87+
end
88+
7489
end
7590

7691
end

build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/errors_module.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def initialize(options)
2020
# @return [String|nil]
2121
def generated_src_warning
2222
return if @service.protocol == 'api-gateway'
23+
2324
GENERATED_SRC_WARNING
2425
end
2526

@@ -42,6 +43,10 @@ def customization_file_path
4243
"#{gem_name}/customizations/errors"
4344
end
4445

46+
def query_protocol?
47+
@service.protocol == 'query'
48+
end
49+
4550
private
4651

4752
# @return [String]

build_tools/aws-sdk-code-generator/templates/errors_module.mustache

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,29 @@ module {{module_name}}
2727
{{=<% %>=}}
2828
# * {<% name %>}
2929
<%={{ }}=%>
30+
{{#query_protocol?}}
31+
{{#custom_error_class?}}
32+
# * This error class is not used. `{{custom_error_class}}` is used during parsing instead.
33+
{{/custom_error_class?}}
34+
{{/query_protocol?}}
3035
{{/errors}}
3136
#
3237
# Additionally, error classes are dynamically generated for service errors based on the error code
3338
# if they are not defined above.
39+
{{#query_protocol?}}
40+
# Some existing error classes may use a different class name than the one documented.
41+
{{/query_protocol?}}
3442
module Errors
3543

3644
extend Aws::Errors::DynamicErrors
3745

3846
{{#errors}}
47+
{{#query_protocol?}}
48+
{{#custom_error_class?}}
49+
# @deprecated This error class is not used during parsing.
50+
# Please use `{{custom_error_class}}` instead.
51+
{{/custom_error_class?}}
52+
{{/query_protocol?}}
3953
class {{name}} < ServiceError
4054

4155
# @param [Seahorse::Client::RequestContext] context

0 commit comments

Comments
 (0)