@@ -86,7 +86,7 @@ static CFStringRef CopyBundleIDForPath(const char *app_bundle_path,
86
86
#if defined(WITH_BKS) || defined(WITH_FBS)
87
87
#import <Foundation/Foundation.h>
88
88
static const int OPEN_APPLICATION_TIMEOUT_ERROR = 111;
89
- typedef void (*SetErrorFunction)(NSInteger, DNBError &);
89
+ typedef void (*SetErrorFunction)(NSInteger, std::string, DNBError &);
90
90
typedef bool (*CallOpenApplicationFunction)(NSString *bundleIDNSStr,
91
91
NSDictionary *options,
92
92
DNBError &error, pid_t *return_pid);
@@ -122,6 +122,7 @@ static bool CallBoardSystemServiceOpenApplication(NSString *bundleIDNSStr,
122
122
mach_port_t client_port = [system_service createClientPort];
123
123
__block dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
124
124
__block ErrorFlavor open_app_error = no_error_enum_value;
125
+ __block std::string open_app_error_string;
125
126
bool wants_pid = (return_pid != NULL);
126
127
__block pid_t pid_in_block;
127
128
@@ -159,6 +160,9 @@ static bool CallBoardSystemServiceOpenApplication(NSString *bundleIDNSStr,
159
160
} else {
160
161
const char *error_str =
161
162
[(NSString *)[bks_error localizedDescription] UTF8String];
163
+ if (error_str) {
164
+ open_app_error_string = error_str;
165
+ }
162
166
DNBLogThreadedIf(LOG_PROCESS, "In completion handler for send "
163
167
"event, got error \"%s\"(%ld).",
164
168
error_str ? error_str : "<unknown error>",
@@ -190,7 +194,7 @@ static bool CallBoardSystemServiceOpenApplication(NSString *bundleIDNSStr,
190
194
error.SetError(OPEN_APPLICATION_TIMEOUT_ERROR, DNBError::Generic);
191
195
error.SetErrorString("timed out trying to launch app");
192
196
} else if (open_app_error != no_error_enum_value) {
193
- error_function(open_app_error, error);
197
+ error_function(open_app_error, open_app_error_string, error);
194
198
DNBLogError("unable to launch the application with CFBundleIdentifier '%s' "
195
199
"bks_error = %u",
196
200
cstr, open_app_error);
@@ -245,19 +249,19 @@ static bool IsBKSProcess(nub_process_t pid) {
245
249
return app_state != BKSApplicationStateUnknown;
246
250
}
247
251
248
- static void SetBKSError(NSInteger error_code, DNBError &error) {
252
+ static void SetBKSError(NSInteger error_code,
253
+ std::string error_description,
254
+ DNBError &error) {
249
255
error.SetError(error_code, DNBError::BackBoard);
250
256
NSString *err_nsstr = ::BKSOpenApplicationErrorCodeToString(
251
257
(BKSOpenApplicationErrorCode)error_code);
252
- const char * err_str = NULL ;
253
- if (err_nsstr == NULL)
254
- err_str = "unknown BKS error" ;
255
- else {
258
+ std::string err_str = "unknown BKS error" ;
259
+ if (error_description.empty() == false) {
260
+ err_str = error_description ;
261
+ } else if (err_nsstr != nullptr) {
256
262
err_str = [err_nsstr UTF8String];
257
- if (err_str == NULL)
258
- err_str = "unknown BKS error";
259
263
}
260
- error.SetErrorString(err_str);
264
+ error.SetErrorString(err_str.c_str() );
261
265
}
262
266
263
267
static bool BKSAddEventDataToOptions(NSMutableDictionary *options,
@@ -355,19 +359,19 @@ static bool IsFBSProcess(nub_process_t pid) {
355
359
}
356
360
#endif
357
361
358
- static void SetFBSError(NSInteger error_code, DNBError &error) {
362
+ static void SetFBSError(NSInteger error_code,
363
+ std::string error_description,
364
+ DNBError &error) {
359
365
error.SetError((DNBError::ValueType)error_code, DNBError::FrontBoard);
360
366
NSString *err_nsstr = ::FBSOpenApplicationErrorCodeToString(
361
367
(FBSOpenApplicationErrorCode)error_code);
362
- const char * err_str = NULL ;
363
- if (err_nsstr == NULL)
364
- err_str = "unknown FBS error" ;
365
- else {
368
+ std::string err_str = "unknown FBS error" ;
369
+ if (error_description.empty() == false) {
370
+ err_str = error_description ;
371
+ } else if (err_nsstr != nullptr) {
366
372
err_str = [err_nsstr UTF8String];
367
- if (err_str == NULL)
368
- err_str = "unknown FBS error";
369
373
}
370
- error.SetErrorString(err_str);
374
+ error.SetErrorString(err_str.c_str() );
371
375
}
372
376
373
377
static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
@@ -2754,7 +2758,8 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
2754
2758
"debugserver timed out waiting for openApplication to complete.");
2755
2759
attach_err.SetError(OPEN_APPLICATION_TIMEOUT_ERROR, DNBError::Generic);
2756
2760
} else if (attach_error_code != FBSOpenApplicationErrorCodeNone) {
2757
- SetFBSError(attach_error_code, attach_err);
2761
+ std::string empty_str;
2762
+ SetFBSError(attach_error_code, empty_str, attach_err);
2758
2763
DNBLogError("unable to launch the application with CFBundleIdentifier "
2759
2764
"'%s' bks_error = %ld",
2760
2765
bundleIDStr.c_str(), (NSInteger)attach_error_code);
@@ -2831,7 +2836,8 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
2831
2836
"debugserver timed out waiting for openApplication to complete.");
2832
2837
attach_err.SetError(OPEN_APPLICATION_TIMEOUT_ERROR, DNBError::Generic);
2833
2838
} else if (attach_error_code != BKSOpenApplicationErrorCodeNone) {
2834
- SetBKSError(attach_error_code, attach_err);
2839
+ std::string empty_str;
2840
+ SetBKSError(attach_error_code, empty_str, attach_err);
2835
2841
DNBLogError("unable to launch the application with CFBundleIdentifier "
2836
2842
"'%s' bks_error = %ld",
2837
2843
bundleIDStr.c_str(), attach_error_code);
0 commit comments