// This file defines test cases that serialize aws.query errors. // // AWS/QUERY serializes errors using the following format: // // // // // Sender // // InvalidParameterValue // // The message contents // // // // 42d59b56-7407-4c4a-be0f-4c88daeea257 // // // The wrapping element name is always "ErrorResponse". It always contains a nested // element named "Error" that is the error structure contents plus other key value // pairs. "ErrorResponse" always has a sibling element named "RequestId" that can // be used to identify the request that caused the failure. // // See: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-api-responses.html#sqs-api-error-response-structure $version: "2.0" namespace aws.protocoltests.query use aws.protocols#awsQueryError use aws.protocols#awsQuery use smithy.test#httpResponseTests /// This operation has three possible return values: /// /// 1. A successful response in the form of GreetingWithErrorsOutput /// 2. An InvalidGreeting error. /// 3. A BadRequest error. operation GreetingWithErrors { output: GreetingWithErrorsOutput, errors: [InvalidGreeting, ComplexError, CustomCodeError] } apply GreetingWithErrors @httpResponseTests([ { id: "QueryGreetingWithErrors", documentation: "Ensures that operations with errors successfully know how to deserialize the successful response", protocol: awsQuery, code: 200, headers: { "Content-Type": "text/xml" }, body: """ Hello """, bodyMediaType: "application/xml", params: { greeting: "Hello" } } ]) structure GreetingWithErrorsOutput { greeting: String, } /// This error is thrown when an invalid greeting value is provided. @error("client") structure InvalidGreeting { Message: String, } apply InvalidGreeting @httpResponseTests([ { id: "QueryInvalidGreetingError", documentation: "Parses simple XML errors", protocol: awsQuery, params: { Message: "Hi" }, code: 400, headers: { "Content-Type": "text/xml" }, body: """ Sender InvalidGreeting Hi foo-id """, bodyMediaType: "application/xml", } ]) /// This error is thrown when a request is invalid. @error("client") structure ComplexError { TopLevel: String, Nested: ComplexNestedErrorData, } apply ComplexError @httpResponseTests([ { id: "QueryComplexError", protocol: awsQuery, params: { TopLevel: "Top level", Nested: { Foo: "bar" } }, code: 400, headers: { "Content-Type": "text/xml" }, body: """ Sender ComplexError Top level bar foo-id """, bodyMediaType: "application/xml", } ]) structure ComplexNestedErrorData { Foo: String, } @awsQueryError( code: "Customized", httpResponseCode: 402, ) @error("client") structure CustomCodeError { Message: String, } apply CustomCodeError @httpResponseTests([ { id: "QueryCustomizedError", documentation: "Parses customized XML errors", protocol: awsQuery, params: { Message: "Hi" }, code: 402, headers: { "Content-Type": "text/xml" }, body: """ Sender Customized Hi foo-id """, bodyMediaType: "application/xml", } ])