AWS SDK for C++  0.12.9
AWS SDK for C++
AWSError.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #pragma once
17 
18 #include <aws/core/Core_EXPORTS.h>
20 
21 namespace Aws
22 {
23  namespace Client
24  {
25  enum class CoreErrors;
26 
30  template<typename ERROR_TYPE>
31  class AWSError
32  {
33  public:
37  AWSError() : m_isRetryable(false) {}
41  AWSError(ERROR_TYPE errorType, Aws::String exceptionName, const Aws::String message, bool isRetryable) :
42  m_errorType(errorType), m_exceptionName(exceptionName), m_message(message), m_isRetryable(isRetryable) {}
46  AWSError(ERROR_TYPE errorType, bool isRetryable) :
47  m_errorType(errorType), m_isRetryable(isRetryable) {}
48 
49  //by policy we enforce all clients to contain a CoreErrors alignment for their Errors.
51  m_errorType(static_cast<ERROR_TYPE>(rhs.GetErrorType())), m_exceptionName(rhs.GetExceptionName()), m_message(rhs.GetMessage()), m_isRetryable(rhs.ShouldRetry())
52  {}
53 
57  inline const ERROR_TYPE GetErrorType() const { return m_errorType; }
61  inline const Aws::String& GetExceptionName() const { return m_exceptionName; }
65  inline void SetExceptionName(const Aws::String& exceptionName) { m_exceptionName = exceptionName; }
69  inline const Aws::String& GetMessage() const { return m_message; }
73  inline void SetMessage(const Aws::String& message) { m_message = message; }
77  inline bool ShouldRetry() const { return m_isRetryable; }
78 
79  private:
80  ERROR_TYPE m_errorType;
81  Aws::String m_exceptionName;
82  Aws::String m_message;
83  bool m_isRetryable;
84  };
85 
86  } // namespace Client
87 } // namespace Aws
const Aws::String & GetMessage() const
Definition: AWSError.h:69
void SetExceptionName(const Aws::String &exceptionName)
Definition: AWSError.h:65
bool ShouldRetry() const
Definition: AWSError.h:77
AWSError(ERROR_TYPE errorType, bool isRetryable)
Definition: AWSError.h:46
const Aws::String & GetExceptionName() const
Definition: AWSError.h:61
AWSError(ERROR_TYPE errorType, Aws::String exceptionName, const Aws::String message, bool isRetryable)
Definition: AWSError.h:41
const ERROR_TYPE GetErrorType() const
Definition: AWSError.h:57
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
void SetMessage(const Aws::String &message)
Definition: AWSError.h:73
AWSError(const AWSError< CoreErrors > &rhs)
Definition: AWSError.h:50
JSON (JavaScript Object Notation).