-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(predictions): new error handling and tests (#3257)
- Loading branch information
Showing
30 changed files
with
524 additions
and
753 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
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
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
31 changes: 31 additions & 0 deletions
31
...ictionsPlugin/Support/Internal/ErrorHandling/Comprehend+PredictionsErrorConvertible.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,31 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import AWSComprehend | ||
import Amplify | ||
|
||
protocol PredictionsErrorConvertible { | ||
var predictionsError: PredictionsError { get } | ||
} | ||
|
||
extension AWSComprehend.InternalServerException: PredictionsErrorConvertible { | ||
var predictionsError: PredictionsError { | ||
.service(.internalServerError) | ||
} | ||
} | ||
|
||
extension AWSComprehend.InvalidRequestException: PredictionsErrorConvertible { | ||
var predictionsError: PredictionsError { | ||
.service(.invalidRequest) | ||
} | ||
} | ||
|
||
extension AWSComprehend.TextSizeLimitExceededException: PredictionsErrorConvertible { | ||
var predictionsError: PredictionsError { | ||
.service(.textSizeLimitExceeded) | ||
} | ||
} |
24 changes: 0 additions & 24 deletions
24
...rnal/ErrorHandling/Comprehend/ServiceErrorMapping+DetectDominantLanguageOutputError.swift
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
...SPredictionsPlugin/Support/Internal/ErrorHandling/Polly+PredictionsErrorConvertible.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,93 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import AWSPolly | ||
import Amplify | ||
|
||
extension AWSPolly.InvalidSampleRateException: PredictionsErrorConvertible { | ||
var predictionsError: PredictionsError { | ||
.service(.invalidSampleRate) | ||
} | ||
} | ||
|
||
extension AWSPolly.LanguageNotSupportedException: PredictionsErrorConvertible { | ||
var predictionsError: PredictionsError { | ||
.service(.unsupportedLanguage) | ||
} | ||
} | ||
|
||
extension AWSPolly.ServiceFailureException: PredictionsErrorConvertible { | ||
var predictionsError: PredictionsError { | ||
.service(.internalServerError) | ||
} | ||
} | ||
|
||
extension AWSPolly.TextLengthExceededException: PredictionsErrorConvertible { | ||
var predictionsError: PredictionsError { | ||
.service(.textSizeLimitExceeded) | ||
} | ||
} | ||
|
||
extension AWSPolly.LexiconNotFoundException: PredictionsErrorConvertible { | ||
var predictionsError: PredictionsError { | ||
.service( | ||
.init( | ||
description: "Amazon Polly can't find the specified lexicon. This could be caused by a lexicon that is missing, its name is misspelled or specifying a lexicon that is in a different region.", | ||
recoverySuggestion: "Verify that the lexicon exists, is in the region (see ListLexicons) and that you spelled its name is spelled correctly. Then try again.", | ||
underlyingError: self | ||
) | ||
) | ||
} | ||
} | ||
|
||
extension AWSPolly.MarksNotSupportedForFormatException: PredictionsErrorConvertible { | ||
var predictionsError: PredictionsError { | ||
.service( | ||
.init( | ||
description: "Speech marks are not supported for the OutputFormat selected.", | ||
recoverySuggestion: "Speech marks are only available for content in json format.", | ||
underlyingError: self | ||
) | ||
) | ||
} | ||
} | ||
|
||
extension AWSPolly.InvalidSsmlException: PredictionsErrorConvertible { | ||
var predictionsError: PredictionsError { | ||
.service( | ||
.init( | ||
description: "The SSML you provided is invalid.", | ||
recoverySuggestion: "Verify the SSML syntax, spelling of tags and values, and then try again.", | ||
underlyingError: self | ||
) | ||
) | ||
} | ||
} | ||
|
||
extension AWSPolly.SsmlMarksNotSupportedForTextTypeException: PredictionsErrorConvertible { | ||
var predictionsError: PredictionsError { | ||
.service( | ||
.init( | ||
description: "SSML speech marks are not supported for plain text-type input.", | ||
recoverySuggestion: "", | ||
underlyingError: self | ||
) | ||
) | ||
} | ||
} | ||
|
||
extension AWSPolly.EngineNotSupportedException: PredictionsErrorConvertible { | ||
var predictionsError: PredictionsError { | ||
.service( | ||
.init( | ||
description: "This engine is not compatible with the voice that you have designated.", | ||
recoverySuggestion: "Choose a new voice that is compatible with the engine or change the engine and restart the operation.", | ||
underlyingError: self | ||
) | ||
) | ||
} | ||
} |
Oops, something went wrong.