File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,8 @@ def request_url(request)
112112 def serialized_error ( response )
113113 body = { }
114114 body [ "errors" ] = response . body [ "errors" ] if response . body [ "errors" ]
115+ body [ "error" ] = response . body [ "error" ] if response . body [ "error" ]
116+ body [ "error_description" ] = response . body [ "error_description" ] if response . body [ "error" ]
115117
116118 if response . headers [ "x-request-id" ]
117119 id = T . must ( response . headers [ "x-request-id" ] ) [ 0 ]
Original file line number Diff line number Diff line change @@ -175,6 +175,27 @@ def test_error_message_structure
175175 assert ( parsed_error [ "error_reference" ] )
176176 end
177177
178+ def test_error_message_with_oauth_error_and_description
179+ error_response_body = {
180+ "error" : "invalid_subject_token" ,
181+ "error_description" : "The subject token is invalid or has expired" ,
182+ } . to_json
183+ response_headers = {
184+ "x-request-id" : 9012 ,
185+ }
186+ stub_request ( @request . http_method , "https://#{ @shop } #{ @base_path } /#{ @request . path } " )
187+ . with ( body : @request . body . to_json , query : @request . query , headers : @expected_headers )
188+ . to_return ( body : error_response_body , status : 400 , headers : response_headers )
189+
190+ response = assert_raises ( ShopifyAPI ::Errors ::HttpResponseError ) do
191+ @client . request ( @request )
192+ end
193+ parsed_error = JSON . parse ( response . message )
194+ assert_equal ( "invalid_subject_token" , parsed_error [ "error" ] )
195+ assert_equal ( "The subject token is invalid or has expired" , parsed_error [ "error_description" ] )
196+ assert ( parsed_error [ "error_reference" ] )
197+ end
198+
178199 def test_non_retriable_error_code
179200 stub_request ( @request . http_method , "https://#{ @shop } #{ @base_path } /#{ @request . path } " )
180201 . with ( body : @request . body . to_json , query : @request . query , headers : @expected_headers )
You can’t perform that action at this time.
0 commit comments