error.h¶
#include <primo/platform/error.h>
Includes¶
primo/platform/reference.h
Classes¶
Name |
Description |
|---|---|
Describes an error interface used for uniform error handling across all Primo Software libraries. |
Namespaces¶
primoprimo::error
Source¶
1#ifndef ___PRIMO_ERROR_INFO_H___
2#define ___PRIMO_ERROR_INFO_H___
3
4#include <primo/platform/reference.h>
5
6/** @file */
7
8// Common definitions
9namespace primo
10{
11 /**
12 Shared namespace for error definitions
13 */
14 namespace error
15 {
16 /**
17 Describes an error interface used for uniform error handling across all Primo Software libraries.
18 */
19 class ErrorInfo : public primo::Reference
20 {
21 public:
22 /**
23 Error code. Its meaning depends on the @link ErrorInfo::facility error facility @endlink.
24
25 @return The error code as defined by the appropriate error facility.
26 */
27 virtual int32_t code() const = 0;
28
29 /**
30 Sets the error code. Its meaning depends on the @link ErrorInfo::facility error facility @endlink.
31
32 @param code An error code
33 */
34 virtual void setCode(int32_t code) = 0;
35
36 /**
37 Error facility. This is the component that reports the error.
38
39 @return An ErrorFacility constant.
40 */
41 virtual int32_t facility() const = 0;
42
43 /**
44 Sets the error faiclity. This is the component that reports the error.
45
46 @param facility An Error facility constant
47 */
48 virtual void setFacility(int32_t facility) = 0;
49
50 /**
51 Error message. This is a textual representation of the error code.
52
53 @note The returned string is never <b>NULL</b>. It is an empty string when the error hint is not set.
54
55 @return Unicode string.
56 */
57 virtual const char_t* message() const = 0;
58
59 /**
60 Sets or clears the error message. It is a textual representation of the error code.
61
62 @param message A pointer to zero terminated Unicode string.
63 Can be <b>NULL</b> in which case the error message is cleared.
64 */
65 virtual void setMessage(const char_t* message) = 0;
66
67 /**
68 Diagnostic hint. This is an implementation specific diagnostics message, suitable for error logs or debugging.
69
70 @note The returned string is never <b>NULL</b>. It is an empty string when the error hint is not set.
71
72 @return Unicode string.
73 */
74 virtual const char_t* hint() const = 0;
75
76 /**
77 Sets or clears the error hint.
78 It is an implementation specific diagnostics message, suitable for error logs or debugging.
79
80 @param hint A pointer to zero terminated Unicode string.
81 Can be <b>NULL</b> in which case the error hint is cleared.
82 */
83 virtual void setHint(const char_t* hint) = 0;
84
85 /**
86 The component that has generated the error.
87
88 @note The returned string is never <b>NULL</b>. It is an empty string when the component is not set.
89
90 @return Unicode string.
91 */
92 virtual const char_t* block() const = 0;
93
94 /**
95 Sets or clears the error block.
96 It is the component that has generated the error.
97
98 @param block A pointer to zero terminated Unicode string.
99 Can be <b>NULL</b> in which case the error block is cleared.
100 */
101 virtual void setBlock(const char_t* block) = 0;
102
103 /**
104 Creates a copy of this object.
105
106 @return A new ErrorInfo object.
107 The caller is responsible for releasing the new object when it is not needed anymore.
108
109 @see primo::Reference::release
110 */
111 virtual const ErrorInfo* clone() const = 0;
112 };
113 }
114} // namespace primo
115
116#endif // ___PRIMO_ERROR_INFO_H___