From 85a442fe827c306e0da047e24b15eb0b87b0638d Mon Sep 17 00:00:00 2001 From: Yoshida Hiroshi Date: Thu, 25 Jan 2024 16:50:16 +0900 Subject: [PATCH] =?UTF-8?q?=E5=85=B1=E9=80=9A=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- amazon_transcribe.go | 47 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/amazon_transcribe.go b/amazon_transcribe.go index 3a5b010..e537875 100644 --- a/amazon_transcribe.go +++ b/amazon_transcribe.go @@ -11,14 +11,55 @@ import ( "github.com/aws/aws-sdk-go/service/transcribestreamingservice" ) +const ( + AccessDeniedException = "AccessDeniedException" + IncompleteSignature = "IncompleteSignature" + InternalFailure = "InternalFailure" + InvalidAction = "InvalidAction" + InvalidClientTokenID = "InvalidClientTokenId" + InvalidParameterCombination = "InvalidParameterCombination" + InvalidParameterValue = "InvalidParameterValue" + InvalidQueryParameter = "InvalidQueryParameter" + MalformedQueryString = "MalformedQueryString" + MissingAction = "MissingAction" + MissingAuthenticationToken = "MissingAuthenticationToken" + MissingParameter = "MissingParameter" + NotAuthorized = "NotAuthorized" + OptInRequired = "OptInRequired" + RequestExpired = "RequestExpired" + ServiceUnavailable = "ServiceUnavailable" + ThrottlingException = "ThrottlingException" + ValidationError = "ValidationError" +) + var ( - // https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartStreamTranscription.html#API_streaming_StartStreamTranscription_Errors - amazonTranscribeStreamingServiceErrors = map[string]int{ + amazonErrors = map[string]int{ + // https://docs.aws.amazon.com/transcribe/latest/APIReference/API_streaming_StartStreamTranscription.html#API_streaming_StartStreamTranscription_Errors transcribestreamingservice.ErrCodeLimitExceededException: 429, transcribestreamingservice.ErrCodeConflictException: 409, transcribestreamingservice.ErrCodeBadRequestException: 400, transcribestreamingservice.ErrCodeInternalFailureException: 500, transcribestreamingservice.ErrCodeServiceUnavailableException: 503, + + // https://docs.aws.amazon.com/transcribe/latest/APIReference/CommonErrors.html + AccessDeniedException: 400, + IncompleteSignature: 400, + InternalFailure: 500, + InvalidAction: 400, + InvalidClientTokenID: 403, + InvalidParameterCombination: 400, + InvalidParameterValue: 400, + InvalidQueryParameter: 400, + MalformedQueryString: 404, + MissingAction: 400, + MissingAuthenticationToken: 403, + MissingParameter: 400, + NotAuthorized: 400, + OptInRequired: 403, + RequestExpired: 400, + ServiceUnavailable: 503, + ThrottlingException: 400, + ValidationError: 400, } ) @@ -108,7 +149,7 @@ func (at *AmazonTranscribe) Start(ctx context.Context, r io.Reader) (*transcribe resp, err := client.StartStreamTranscriptionWithContext(ctx, &input) if err != nil { if awsErr, ok := err.(awserr.Error); ok { - code, ok := amazonTranscribeStreamingServiceErrors[awsErr.Code()] + code, ok := amazonErrors[awsErr.Code()] if !ok { return nil, err }