1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     err_Api.h
4 
5   Copyright (C)2010 Nintendo Co., Ltd.  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   $Rev: 38846 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_ERR_CTR_ERR_API_H_
17 #define NN_ERR_CTR_ERR_API_H_
18 
19 #include <nn/types.h>
20 #include <nn/Result.h>
21 
22 #ifdef __cplusplus
23 namespace nn {
24 namespace err {
25 namespace CTR {
26 
27     // On the development hardware, when an error occurs in the library, instead of stopping, it is treated as a fatal error.
28     //
29     void SetupResultHandler( void );
30 
31     // Do not directly call the following function. Use the NN_ERR_THROW_* macro.
32     void ThrowFatalErr( Result result );
33     void ThrowFatalErrAll( Result result );
34 
35 }}} // namespace nn::err::CTR
36 
37 #ifndef NN_HARDWARE_CTR_LEGACY
38 #ifdef NN_PROCESSOR_ARM11MPCORE
39 
40 /*
41     A FATAL error is thrown to the error display applet.
42     An actual notification occurs only when the Result's LEVEL is FATAL.
43  */
44 #define NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result) \
45     do \
46     { \
47         ::nn::Result resultLocal = (result); \
48         if ( resultLocal.GetLevel() == ::nn::Result::LEVEL_FATAL ) \
49         { \
50             ::nn::err::ThrowFatalErrAll(resultLocal); \
51         } \
52     } while(0)
53 
54 /*
55     A FATAL error is thrown to the error display applet.
56     An actual notification occurs when the Result LEVEL is not SUCCESS/STATUS/INFO (not recommended) (for fatal errors or errors that should not occur on the production device).
57 
58 
59  */
60 #define NN_ERR_THROW_FATAL(result) \
61     do \
62     { \
63         ::nn::Result resultLocal = (result); \
64         if ( resultLocal.IsFailure() ) \
65         { \
66             ::nn::err::ThrowFatalErr(resultLocal); \
67         } \
68     } while(0)
69 
70 /*
71     A FATAL error is thrown to the error display applet.
72     Notifies for all Results that are errors.
73  */
74 #define NN_ERR_THROW_FATAL_ALL(result) \
75     do \
76     { \
77         ::nn::Result resultLocal = (result); \
78         if ( resultLocal.IsFailure() ) \
79         { \
80             ::nn::err::ThrowFatalErrAll(resultLocal); \
81         } \
82     } while(0)
83 
84 
85 #else /* NN_PROCESSOR_ARM11MPCORE */
86 
87 #define NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result)    NN_UTIL_PANIC_IF_FAILED(result)
88 #define NN_ERR_THROW_FATAL(result)                  NN_UTIL_PANIC_IF_FAILED(result)
89 #define NN_ERR_THROW_FATAL_ALL(result)              NN_UTIL_PANIC_IF_FAILED(result)
90 
91 #endif /* NN_PROCESSOR_ARM11MPCORE */
92 #else /* NN_HARDWARE_CTR_LEGACY */
93 
94 #define NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result) \
95     do \
96     { \
97         ::nn::Result resultLocal = (result); \
98         NN_UNUSED_VAR(resultLocal); \
99     } while(0)
100 
101 #define NN_ERR_THROW_FATAL(result) \
102     do \
103     { \
104         ::nn::Result resultLocal = (result); \
105         NN_UNUSED_VAR(resultLocal); \
106     } while(0)
107 
108 #define NN_ERR_THROW_FATAL_ALL(result) \
109     do \
110     { \
111         ::nn::Result resultLocal = (result); \
112         NN_UNUSED_VAR(resultLocal); \
113     } while(0)
114 
115 #endif /* NN_HARDWARE_CTR_LEGACY */
116 #endif // __cplusplus
117 
118 
119 #endif /* NN_ERR_CTR_ERR_API_H_ */
120