1 //===-- DNBError.cpp --------------------------------------------*- 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 //===----------------------------------------------------------------------===//
17 #include "PThreadMutex.h"
19 #ifdef WITH_SPRINGBOARD
20 #include <SpringBoardServices/SpringBoardServer.h>
23 const char *DNBError::AsString() const {
31 s = ::mach_error_string(m_err);
35 s = ::strerror(m_err);
38 #ifdef WITH_SPRINGBOARD
40 CFStringRef statusStr = SBSApplicationLaunchingErrorString(m_err);
41 if (CFString::UTF8(statusStr, m_str) == NULL)
47 // You have to call ObjC routines to get the error string from
49 // Not sure I want to make DNBError.cpp an .mm file. For now just make
51 // pre-populate the error string when you make the DNBError of type
54 "Should have set BackBoard error when making the error string.");
59 // You have to call ObjC routines to get the error string from
60 // FrontBoardServices.
61 // Not sure I want to make DNBError.cpp an .mm file. For now just make
63 // pre-populate the error string when you make the DNBError of type
66 "Should have set FrontBoard error when making the error string.");
80 void DNBError::LogThreadedIfError(const char *format, ...) const {
84 va_start(args, format);
85 ::vasprintf(&arg_msg, format, args);
88 if (arg_msg != NULL) {
89 const char *err_str = AsString();
92 DNBLogThreaded("error: %s err = %s (0x%8.8x)", arg_msg, err_str, m_err);
98 void DNBError::LogThreaded(const char *format, ...) const {
101 va_start(args, format);
102 ::vasprintf(&arg_msg, format, args);
105 if (arg_msg != NULL) {
107 const char *err_str = AsString();
110 DNBLogThreaded("error: %s err = %s (0x%8.8x)", arg_msg, err_str, m_err);
112 DNBLogThreaded("%s err = 0x%8.8x", arg_msg, m_err);