From 5efab2c13073a826d490fe3bae9ff19460c891b0 Mon Sep 17 00:00:00 2001 From: evalphobia Date: Thu, 1 Mar 2018 17:04:32 +0900 Subject: [PATCH] [rekognition] Add helper method for InvalidParameterException error (#27) --- rekognition/error.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/rekognition/error.go b/rekognition/error.go index a3f678a..b5b5cfe 100644 --- a/rekognition/error.go +++ b/rekognition/error.go @@ -2,7 +2,10 @@ package rekognition import "strings" -var msgInvalidImageEncoding = `InvalidImageFormatException: Invalid image encoding` +const ( + msgInvalidImageEncoding = `InvalidImageFormatException: Invalid image encoding` + msgInvalidParameter = `InvalidParameterException: Request has Invalid Parameters` +) // IsErrorInvalidImageEncoding checks if gicen error is `Invalid image encoding`. func IsErrorInvalidImageEncoding(err error) (ok bool) { @@ -12,3 +15,12 @@ func IsErrorInvalidImageEncoding(err error) (ok bool) { return strings.Contains(err.Error(), msgInvalidImageEncoding) } + +// IsErrorInvalidParameter checks if gicen error is `Invalid image encoding`. +func IsErrorInvalidParameter(err error) (ok bool) { + if err == nil { + return false + } + + return strings.Contains(err.Error(), msgInvalidImageEncoding) +}