7d7c1634e357a4dc970b41f301d33bc2294ec300
[platform/core/location/maps-plugin-here.git] / inc / engine / common / CommunicationError.h
1 /*
2  * Copyright (C) 2013 HERE Global B.V. All rights reserved.
3  * This software, including documentation, is protected by copyright controlled by
4  * HERE Global B.V. (“Software”). All rights are reserved. Copying, including reproducing,
5  * storing, adapting or translating, any or all of this material requires the prior
6  * written consent of HERE Global B.V. You may use this
7  * Software in accordance with the terms and conditions defined in the
8  * HERE Location Platform Services Terms and Conditions, available at
9  * http://developer.here.com/terms-conditions-base
10  *
11  * As an additional permission to the above, you may distribute Software,
12  * in object code format as part of an Application, according to, and subject to, terms and
13  * conditions defined in the Tizen Software Development kit (“SDK”) License Agreement.
14  * You may distribute such object code format Application under terms of your choice,
15  * provided that the header and source files of the Software have not been modified.
16  */
17
18 #ifndef COMMUNICATIONERROR_H
19 #define COMMUNICATIONERROR_H
20
21 #include "common/HereMaps_global.h"
22 #include "common/ErrorBase.h"
23
24 #ifndef TIZEN_MIGRATION
25 #include <FNet.h>
26 #endif
27
28 HERE_MAPS_BEGIN_NAMESPACE
29
30 /**
31  * This class encapsulates information about an error condition that may arise
32  * in network communications between the client and the server.
33  */
34 class EXPORT_API CommunicationError : public ErrorBase
35 {
36 public:
37     /** 
38      * This enumeration defines error code identifiers. 
39      */
40     enum ErrorCode
41     {
42         CE_HttpError,       ///< Indicates an HTTP error.
43         CE_NetworkError,    ///< Indicates a network error.
44         CE_RestEngineError, ///< Indicates a REST engine error.
45         CE_MaxRequests      ///< Indicates that the maximum number of requests
46                             ///  has been reached.
47     };
48
49     /**
50      * This typedef defines a HTTP status code as a type.
51      */
52 #ifdef TIZEN_MIGRATION
53     typedef long HttpStatusCode;
54 #else
55     typedef Tizen::Net::Http::NetHttpStatusCode HttpStatusCode;
56 #endif
57
58     /**
59      * This method is a constructor.
60      * 
61      * @param aErrorCode A value representing an error code.
62      */
63     CommunicationError(ErrorCode aErrorCode);
64
65     /**
66      * This method is a constructor.
67      * 
68      * @param aHttpStatusCode A value representing an HTTP status code as
69      *        defined on http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
70      */
71     CommunicationError(HttpStatusCode aHttpStatusCode);
72
73     /**
74      * This method is a (virtual) destructor.
75      *
76      */
77     virtual ~CommunicationError();
78
79     /**
80      * This method retrieves an error code.
81      * 
82      * @return A value representing an error code.
83      */
84     ErrorCode GetErrorCode() const;
85
86     /**
87      * This method retrieves a string representation of the given instance of
88      * <code>CommunicationError</code>.
89      *
90      * @return A string representation of the given instance of
91      * <code>CommunicationError</code>.
92      */
93     virtual String ToString() const;
94
95     /**
96      * This method sets an HTTP status code.
97      *
98      * @param aHttpStatusCode A value representing an HTTP status code as
99      *        defined on http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
100      */
101     void SetHttpStatusCode(HttpStatusCode aHttpStatusCode);
102
103 #ifdef TIZEN_MIGRATION
104     /**
105      * This method retrieves the HTTP status code associated with the given
106      * instance of the class. 
107      *
108      * @return aHttpStatusCode A value representing an HTTP status code as
109      *        defined on http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
110      */
111     const HttpStatusCode GetHttpStatusCode();
112 #endif
113
114     /**
115      * This method associates a text string describing an error with the given
116      * instance of the class. 
117      * 
118      * @param sDesc A constant reference to a string containing the error
119      *        description.
120      */
121     void SetErrorDescription(const String& sDesc);
122
123     /**
124      * This method retrieves the error description associated with the given
125      * instance of the class. 
126      * 
127      * @return A constant reference to a string containing the error
128      *        description.
129      */
130     const String& GetErrorDescription() const;
131
132 private:
133     HERE_MAPS_NO_COPY_NO_ASSIGN(CommunicationError);
134
135     class CommunicationErrorImpl;
136     CommunicationErrorImpl* m_pImpl;
137
138 };
139
140 HERE_MAPS_END_NAMESPACE
141
142 #endif