text: ﻿/*
  * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License").
  * You may not use this file except in compliance with the License.
  * A copy of the License is located at
  *
  *  http://aws.amazon.com/apache2.0
  *
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
  
  #include <aws/core/client/AWSError.h>
  #include <aws/core/utils/HashingUtils.h>
  #include <aws/kinesis/KinesisErrors.h>
  
  using namespace Aws::Client;
  using namespace Aws::Kinesis;
  using namespace Aws::Utils;
  
  namespace Aws
  {
  namespace Kinesis
  {
  namespace KinesisErrorMapper
  {
  
  static const int K_M_S_OPT_IN_REQUIRED_HASH = HashingUtils::HashString("KMSOptInRequired");
  static const int K_M_S_DISABLED_HASH = HashingUtils::HashString("KMSDisabledException");
  static const int K_M_S_ACCESS_DENIED_HASH = HashingUtils::HashString("KMSAccessDeniedException");
  static const int K_M_S_NOT_FOUND_HASH = HashingUtils::HashString("KMSNotFoundException");
  static const int K_M_S_INVALID_STATE_HASH = HashingUtils::HashString("KMSInvalidStateException");
  static const int EXPIRED_ITERATOR_HASH = HashingUtils::HashString("ExpiredIteratorException");
  static const int LIMIT_EXCEEDED_HASH = HashingUtils::HashString("LimitExceededException");
  static const int K_M_S_THROTTLING_HASH = HashingUtils::HashString("KMSThrottlingException");
  static const int RESOURCE_IN_USE_HASH = HashingUtils::HashString("ResourceInUseException");
  static const int PROVISIONED_THROUGHPUT_EXCEEDED_HASH = HashingUtils::HashString("ProvisionedThroughputExceededException");
  static const int INVALID_ARGUMENT_HASH = HashingUtils::HashString("InvalidArgumentException");
  static const int EXPIRED_NEXT_TOKEN_HASH = HashingUtils::HashString("ExpiredNextTokenException");
  
  
  AWSError<CoreErrors> GetErrorForName(const char* errorName)
  {
    int hashCode = HashingUtils::HashString(errorName);
  
    if (hashCode == K_M_S_OPT_IN_REQUIRED_HASH)
    {
      return AWSError<CoreErrors>(static_cast<CoreErrors>(KinesisErrors::K_M_S_OPT_IN_REQUIRED), false);
    }
    else if (hashCode == K_M_S_DISABLED_HASH)
    {
      return AWSError<CoreErrors>(static_cast<CoreErrors>(KinesisErrors::K_M_S_DISABLED), false);
    }
    else if (hashCode == K_M_S_ACCESS_DENIED_HASH)
    {
      return AWSError<CoreErrors>(static_cast<CoreErrors>(KinesisErrors::K_M_S_ACCESS_DENIED), false);
    }
    else if (hashCode == K_M_S_NOT_FOUND_HASH)
    {
      return AWSError<CoreErrors>(static_cast<CoreErrors>(KinesisErrors::K_M_S_NOT_FOUND), false);
    }
    else if (hashCode == K_M_S_INVALID_STATE_HASH)
    {
      return AWSError<CoreErrors>(static_cast<CoreErrors>(KinesisErrors::K_M_S_INVALID_STATE), false);
    }
    else if (hashCode == EXPIRED_ITERATOR_HASH)
    {
      return AWSError<CoreErrors>(static_cast<CoreErrors>(KinesisErrors::EXPIRED_ITERATOR), false);
    }
    else if (hashCode == LIMIT_EXCEEDED_HASH)
    {
      return AWSError<CoreErrors>(static_cast<CoreErrors>(KinesisErrors::LIMIT_EXCEEDED), false);
    }
    else if (hashCode == K_M_S_THROTTLING_HASH)
    {
      return AWSError<CoreErrors>(static_cast<CoreErrors>(KinesisErrors::K_M_S_THROTTLING), false);
    }
    else if (hashCode == RESOURCE_IN_USE_HASH)
    {
      return AWSError<CoreErrors>(static_cast<CoreErrors>(KinesisErrors::RESOURCE_IN_USE), false);
    }
    else if (hashCode == PROVISIONED_THROUGHPUT_EXCEEDED_HASH)
    {
      return AWSError<CoreErrors>(static_cast<CoreErrors>(KinesisErrors::PROVISIONED_THROUGHPUT_EXCEEDED), true);
    }
    else if (hashCode == INVALID_ARGUMENT_HASH)
    {
      return AWSError<CoreErrors>(static_cast<CoreErrors>(KinesisErrors::INVALID_ARGUMENT), false);
    }
    else if (hashCode == EXPIRED_NEXT_TOKEN_HASH)
    {
      return AWSError<CoreErrors>(static_cast<CoreErrors>(KinesisErrors::EXPIRED_NEXT_TOKEN), false);
    }
    return AWSError<CoreErrors>(CoreErrors::UNKNOWN, false);
  }
  
  } // namespace KinesisErrorMapper
  } // namespace Kinesis
  } // namespace Aws
  