Skip to content

Commit

Permalink
Merge pull request #73 from amzn/decode_internal_server_errors
Browse files Browse the repository at this point in the history
Correctly decode internalServer errors.
  • Loading branch information
tachyonics authored Aug 11, 2023
2 parents 6d5f1bd + 65c69bf commit 2f43520
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public extension ServiceModelCodeGenerator {

fileBuilder.appendLine("""
public enum \(baseName)UnmodeledError: Swift.Error {
case internalServer
case deserializationError(cause: Swift.Error)
}
public \(entityType) \(baseName)Error: Swift.Error, Decodable {
""")
fileBuilder.incIndent()
Expand Down Expand Up @@ -174,6 +179,11 @@ public extension ServiceModelCodeGenerator {
""")
}

fileBuilder.appendLine("""
case internalServerErrorIdentityBuiltIn:
throw \(baseName)UnmodeledError.internalServer
""")

// add any additional error decode statements from the delegate
delegate.errorTypeAdditionalErrorDecodeStatementsGenerator(
fileBuilder: fileBuilder,
Expand All @@ -190,6 +200,11 @@ public extension ServiceModelCodeGenerator {
""")
}

fileBuilder.appendLine("""
private let internalServerErrorIdentityBuiltIn = "InternalError"
""")

// for each of the errors
for error in sortedErrors {
let identityName = getNormalizedVariableName(
Expand Down

0 comments on commit 2f43520

Please sign in to comment.