1 //===-- DNBError.h ----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Created by Greg Clayton on 6/26/07.
12 //===----------------------------------------------------------------------===//
14 #ifndef __DNBError_h__
15 #define __DNBError_h__
18 #include <mach/mach.h>
25 typedef uint32_t ValueType;
31 #ifdef WITH_SPRINGBOARD
42 explicit DNBError( ValueType err = 0,
43 FlavorType flavor = Generic) :
49 const char * AsString() const;
50 void Clear() { m_err = 0; m_flavor = Generic; m_str.clear(); }
51 ValueType Error() const { return m_err; }
52 FlavorType Flavor() const { return m_flavor; }
54 ValueType operator = (kern_return_t err)
57 m_flavor = MachKernel;
62 void SetError(kern_return_t err)
65 m_flavor = MachKernel;
69 void SetErrorToErrno()
76 void SetError(ValueType err, FlavorType flavor)
83 // Generic errors can set their own string values
84 void SetErrorString(const char *err_str)
86 if (err_str && err_str[0])
91 bool Success() const { return m_err == 0; }
92 bool Fail() const { return m_err != 0; }
93 void LogThreadedIfError(const char *format, ...) const;
94 void LogThreaded(const char *format, ...) const;
98 mutable std::string m_str;
102 #endif // #ifndef __DNBError_h__