#ifndef __HWS_REQUEST_ERROR_H__ #define __HWS_REQUEST_ERROR_H__ #include <QString> #include <QSharedPointer> namespace hws { /// \brief Capture errors from different kinds of remote calls. /// /// Each request of the system might result in an error. Some errors - those /// typically in the 400 range - might have diagnostic information for the /// user. This mostly encapsulates the diagnostic information. /// /// See our internal documentation page: /// https://confluence.perforce.com:8443/display/WS/Web+Services+Home class RequestError { public: // Error codes in use by errors not detected by the underlying system. /// A generic networking problem (flagged by Qt) const static int NETWORK_ERROR = 16000; /// A networking problem with SSL (flagged by Qt subsystem) const static int SSL_ERROR = 16001; /// A problem parsing JSON const static int JSON_ERROR = 16002; /// The session is likely invalid const static int AUTHENTICATION_ERROR = 16003; /// Problems connecting to the notifications server. const static int WEB_SOCKET_ERROR = 16004; /// The severity of the problem. /// /// For completeness, we include EMPTY, INFO, and WARN, which map to /// the severity of errors potentially reported by the underlying /// p4d instance. In practice, these should almost never happen. /// /// Most errors will have ERROR level, which means you should not /// retry what you just did. /// /// Errors at a FATAL level may require your client to stop accessing /// the server. Something very bad has occurred. enum Severity { EMPTY = 0, INFO = 1, WARN = 2, ERROR = 3, FATAL = 4 }; /// Creates a new request status for a successful operation. RequestError(); /// Create a request status from all fields of a failed request. RequestError(const QString & messageText, const QString & baseMessageText, int code, short severity); /// Copy the request error RequestError(const RequestError & error); /// Typical destructor ~RequestError(); /// Copy state from an existing RequestError RequestError & operator=(const RequestError & e); /// Possibly localized string coming from the server. const QString & messageText() const; /// Set the localized string void setMessageText(const QString & t); /// Underling message, suitable for logging const QString & baseMessageText() const; /// Underling message, suitable for logging void setBaseMessageText(const QString & t); /// See error code constants defined in RequestError.h int code() const; /// See error code constants defined in RequestError.h void setCode(int c); /// Current severity, probably ERROR short severity() const; /// Set the severity void setSeverity(short s); private: QString mMessageText; QString mBaseMessageText; int mCode; short mSeverity; }; typedef QSharedPointer<RequestError> RequestErrorPtr; // If the content in the byte array is actually a JSON error response, then // this will generate a RequestError instance. If it is not, will return an // empty pointer. RequestErrorPtr parseRequestError(QByteArray content); } #endif // __HWS_REQUEST_ERROR_H__
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 15688 | Doug Scheirer |
Populate -o //guest/perforce_software/helix-web-services/... //guest/doug_scheirer/helix-web-services/.... |
||
//guest/perforce_software/helix-web-services/main/build/helix_web_services_client_qt/hws/RequestError.h | |||||
#1 | 14050 | tjuricek | Prep versioned release directory for inclusion into Helix Sync app. |