CTR Pia  4.11.3
Game Communication Engine
common_ErrorHandler.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: common_ErrorHandler.h
4 
5  Copyright Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12  *---------------------------------------------------------------------------*/
13 
14 
15 #pragma once
16 
17 #include <pia/common/common_definitions.h>
18 #include <pia/common/common_Trace.h>
19 
20 #if NN_PIA_ENABLE_TRACE
21 
22 /*!
23 @brief Outputs a trace of <tt>Result</tt> in the Pia module.
24 
25 @param result Specifies the value of <tt>Result</tt>.
26 */
27 #define PIA_TRACE_RESULT(result) \
28  \
29 { \
30  PIA_TRACE(nn::pia::common::TRACE_FLAG_ALWAYS, "%s, line: %d", PIA_CODE_POSITION_FILE, PIA_CODE_POSITION_LINE); \
31  nn::pia::common::ErrorHandler::TraceResult(result); \
32  \
33 }
34 
35 #else // else of NN_PIA_ENABLE_TRACE
36 
37 #define PIA_TRACE_RESULT(result) (void)(result)
38 
39 #endif // end of NN_PIA_ENABLE_TRACE
40 
41 namespace nn
42 {
43 namespace pia
44 {
45 namespace common
46 {
47 
48 
49 /*!
50 @brief This class is used for error handling.
51 
52 @date 2012-07-11 Deleted the <tt>Severity</tt>-related code that was scheduled for removal.
53 @date 2011-12-07 Added a table to the <tt>GetSeverity</tt> page that shows the relationship between each <tt>Result</tt> used in the Pia module and the associated severity.
54 */
56 {
57 public:
58 /*!
59 @brief Displays detailed information for <tt>nn::Result</tt> values.
60 @param[in] result The <tt>nn::Result</tt> value to trace.
61 */
62  static void TraceResult(const nn::Result& result);
63 
64 /*!
65 @brief Displays detailed information for <tt>nn::Result</tt> values.
66 
67 @param[in] traceFlags Specifies trace flags. For more information, see <tt>@ref TraceFlag</tt>.
68 @param[in] result The <tt>nn::Result</tt> value to trace.
69 */
70  static void TraceResult(u64 traceFlags, const nn::Result& result);
71 
72 /*!
73 @brief Determines whether there is an error in the Pia module.
74 @param[in] result Specifies the <tt>nn::Result</tt> value to check.
75 @return Returns <tt>true</tt> if the value is a Pia module <tt>Result</tt>, and returns <tt>false</tt> otherwise.
76 */
77  static bool IsPiaError(const nn::Result& result);
78 
79 /*!
80 @brief Gets the Pia module in which the error occurred.
81 @param[in] result Specifies the <tt>nn::Result</tt> value to be checked by the module.
82 @return Returns the module type using <tt>@ref nn::pia::ModuleType</tt>.
83 */
84  static ModuleType GetModuleTypeFromResult(const nn::Result& result);
85 
86 
87 private:
88 /*!
89 @brief This constructor is private because it does not create an instance.
90 */
91  ErrorHandler(void);
92 
93 /*!
94 @brief This destructor is private.
95 */
96  ~ErrorHandler(void);
97 
98 /*!
99 @brief This copy constructor is private.
100 */
101  ErrorHandler(const ErrorHandler&);
102 
103 /*!
104 @brief This assignment operator is private.
105 */
106  ErrorHandler& operator=(const ErrorHandler&);
107 };
108 }
109 }
110 } // end of namespace nn::pia::common
Definition: assert.h:115
ModuleType
Enumerates modules in the Pia library. You get one of these values when you pass a nn::Result value t...
Definition: result.h:54
This class is used for error handling.
Definition: common_ErrorHandler.h:55
static ModuleType GetModuleTypeFromResult(const nn::Result &result)
Gets the Pia module in which the error occurred.
static bool IsPiaError(const nn::Result &result)
Determines whether there is an error in the Pia module.
static void TraceResult(const nn::Result &result)
Displays detailed information for nn::Result values.