1 //===-- DNBError.cpp --------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // Created by Greg Clayton on 6/26/07.
11 //===----------------------------------------------------------------------===//
16 #include "PThreadMutex.h"
18 #ifdef WITH_SPRINGBOARD
19 #include <SpringBoardServices/SpringBoardServer.h>
22 const char *DNBError::AsString() const {
30 s
= ::mach_error_string(m_err
);
34 s
= ::strerror(m_err
);
37 #ifdef WITH_SPRINGBOARD
39 CFStringRef statusStr
= SBSApplicationLaunchingErrorString(m_err
);
40 if (CFString::UTF8(statusStr
, m_str
) == NULL
)
46 // You have to call ObjC routines to get the error string from
48 // Not sure I want to make DNBError.cpp an .mm file. For now just make
50 // pre-populate the error string when you make the DNBError of type
53 "Should have set BackBoard error when making the error string.");
58 // You have to call ObjC routines to get the error string from
59 // FrontBoardServices.
60 // Not sure I want to make DNBError.cpp an .mm file. For now just make
62 // pre-populate the error string when you make the DNBError of type
65 "Should have set FrontBoard error when making the error string.");
79 void DNBError::LogThreadedIfError(const char *format
, ...) const {
83 va_start(args
, format
);
84 ::vasprintf(&arg_msg
, format
, args
);
87 if (arg_msg
!= NULL
) {
88 const char *err_str
= AsString();
91 DNBLogThreaded("error: %s err = %s (0x%8.8x)", arg_msg
, err_str
, m_err
);
97 void DNBError::LogThreaded(const char *format
, ...) const {
100 va_start(args
, format
);
101 ::vasprintf(&arg_msg
, format
, args
);
104 if (arg_msg
!= NULL
) {
106 const char *err_str
= AsString();
109 DNBLogThreaded("error: %s err = %s (0x%8.8x)", arg_msg
, err_str
, m_err
);
111 DNBLogThreaded("%s err = 0x%8.8x", arg_msg
, m_err
);