-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Closure-based reader-writer serde for JSON, FormURL (#1439)
- Loading branch information
Showing
109 changed files
with
1,571 additions
and
3,747 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
Sources/Core/AWSClientRuntime/Errors/RestXMLError+AWS.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Sources/Core/AWSClientRuntime/Protocols/AWSJSON/AWSJSONError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import protocol ClientRuntime.BaseError | ||
import enum ClientRuntime.BaseErrorDecodeError | ||
import class ClientRuntime.HttpResponse | ||
import class SmithyJSON.Reader | ||
|
||
public struct AWSJSONError: BaseError { | ||
public let code: String | ||
public let message: String? | ||
public let requestID: String? | ||
public var errorBodyReader: Reader { responseReader } | ||
|
||
public let httpResponse: HttpResponse | ||
private let responseReader: Reader | ||
|
||
public init(httpResponse: HttpResponse, responseReader: Reader, noErrorWrapping: Bool) throws { | ||
let code: String? = try httpResponse.headers.value(for: "X-Amzn-Errortype") | ||
?? responseReader["code"].readIfPresent() | ||
?? responseReader["__type"].readIfPresent() | ||
let message: String? = try responseReader["Message"].readIfPresent() | ||
let requestID: String? = try responseReader["RequestId"].readIfPresent() | ||
guard let code else { throw BaseErrorDecodeError.missingRequiredData } | ||
self.code = sanitizeErrorType(code) | ||
self.message = message | ||
self.requestID = requestID | ||
self.httpResponse = httpResponse | ||
self.responseReader = responseReader | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Sources/Core/AWSClientRuntime/Protocols/AWSQuery/AWSQueryError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import protocol ClientRuntime.BaseError | ||
import enum ClientRuntime.BaseErrorDecodeError | ||
import class ClientRuntime.HttpResponse | ||
import class SmithyXML.Reader | ||
|
||
public struct AWSQueryError: BaseError { | ||
public let code: String | ||
public let message: String? | ||
public let requestID: String? | ||
public let httpResponse: HttpResponse | ||
public let responseReader: Reader | ||
public let errorBodyReader: Reader | ||
|
||
public init(httpResponse: HttpResponse, responseReader: Reader, noErrorWrapping: Bool) throws { | ||
self.errorBodyReader = noErrorWrapping ? responseReader : responseReader["Error"] | ||
let code: String? = try errorBodyReader["Code"].readIfPresent() | ||
let message: String? = try errorBodyReader["Message"].readIfPresent() | ||
let requestID: String? = try responseReader["RequestId"].readIfPresent() | ||
guard let code else { throw BaseErrorDecodeError.missingRequiredData } | ||
self.code = code | ||
self.message = message | ||
self.requestID = requestID | ||
self.httpResponse = httpResponse | ||
self.responseReader = responseReader | ||
} | ||
} | ||
|
||
public enum AWSQueryDecodeError: Error { | ||
case missingRequiredData | ||
} |
35 changes: 35 additions & 0 deletions
35
Sources/Core/AWSClientRuntime/Protocols/Ec2Query/EC2QueryError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import protocol ClientRuntime.BaseError | ||
import enum ClientRuntime.BaseErrorDecodeError | ||
import class ClientRuntime.HttpResponse | ||
import class SmithyXML.Reader | ||
|
||
public struct EC2QueryError: BaseError { | ||
public let code: String | ||
public let message: String? | ||
public let requestID: String? | ||
public let errorBodyReader: Reader | ||
|
||
public let httpResponse: HttpResponse | ||
public let responseReader: Reader | ||
|
||
public init(httpResponse: HttpResponse, responseReader: Reader, noErrorWrapping: Bool) throws { | ||
self.httpResponse = httpResponse | ||
self.responseReader = responseReader | ||
self.errorBodyReader = responseReader["Errors"]["Error"] | ||
let code: String? = try errorBodyReader["Code"].readIfPresent() | ||
guard let code else { throw BaseErrorDecodeError.missingRequiredData } | ||
let message: String? = try errorBodyReader["Message"].readIfPresent() | ||
let requestID: String? = try responseReader["RequestId"].readIfPresent() | ||
?? responseReader["RequestID"].readIfPresent() | ||
self.code = code | ||
self.message = message | ||
self.requestID = requestID | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
Sources/Core/AWSClientRuntime/Protocols/Ec2Query/Ec2Error.swift
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
Sources/Core/AWSClientRuntime/Protocols/Ec2Query/Ec2Errors.swift
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
Sources/Core/AWSClientRuntime/Protocols/Ec2Query/Ec2NarrowedError.swift
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
Sources/Core/AWSClientRuntime/Protocols/Ec2Query/Ec2NarrowedResponse.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.