HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
error.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_BASE_ARCH_ERROR_H
8 #define PXR_BASE_ARCH_ERROR_H
9 
10 /// \file arch/error.h
11 /// \ingroup group_arch_Diagnostics
12 /// Low-level fatal error reporting.
13 
14 #include "pxr/pxr.h"
15 #include "pxr/base/arch/api.h"
16 #include "pxr/base/arch/defines.h"
18 #include <stddef.h>
19 
21 
22 /// Print message to standard error and abort program.
23 ///
24 /// \param msg The reason for the failure.
25 /// \param funcName The name of the function that \c Arch_Error was called from.
26 /// \param lineNo The line number of the file that \c Arch_Error was called from.
27 /// \param fileName The name of the file that \c Arch_Error was called from.
28 ///
29 /// \private
30 [[noreturn]]
32 void Arch_Error(const char* msg, const char* funcName,
33  size_t lineNo, const char* fileName);
34 
35 /// Print warning message to standard error, but continue execution.
36 ///
37 /// \param msg The reason for the warning.
38 /// \param funcName The name of the function that \c Arch_Warning was called from.
39 /// \param lineNo The line number of the file that \c Arch_Warning was called from.
40 /// \param fileName The name of the file that \c Arch_Warning was called from.
41 ///
42 /// \private
44 void Arch_Warning(const char* msg, const char* funcName,
45  size_t lineNo, const char* fileName);
46 
47 /// \addtogroup group_arch_Diagnostics
48 ///@{
49 
50 /// Unconditionally aborts the program.
51 ///
52 /// \param msg is a literal string, a \c const \c char* (but not
53 /// an \c std::string) that describes why the program is aborting.
54 /// \hideinitializer
55 #define ARCH_ERROR(msg) \
56  Arch_Error(msg, __ARCH_FUNCTION__, __LINE__, __ARCH_FILE__)
57 
58 /// Prints a warning message to stderr.
59 ///
60 /// \param msg is a literal string, a \c const \c char* (but not
61 /// an \c std::string).
62 /// \hideinitializer
63 #define ARCH_WARNING(msg) \
64  Arch_Warning(msg, __ARCH_FUNCTION__, __LINE__, __ARCH_FILE__)
65 
66 /// Aborts the program if \p cond evaluates to false.
67 /// \hideinitializer
68 #define ARCH_AXIOM(cond) \
69  if (!(cond)) ARCH_ERROR("[" #cond "] axiom failed")
70 
71 ///@}
72 
74 
75 #endif // PXR_BASE_ARCH_ERROR_H
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
#define ARCH_API
Definition: api.h:23