NSDistributedNotificationCenter: Throw a descriptive exception when gdnc could not be found

`NSTask launchPathForTool: @"gdnc"];` can return `nil` when the tool is not found.  In this case, `[NSTask launchedTaskWithLaunchPath]` would raise a `NSInvalidArgumentException` with error message "NSTask - no launch path set" which is not very descriptive.
This commit is contained in:
Frederik Carlier 2023-10-11 16:29:56 +02:00
parent bf586eca1b
commit b9f3bb4d76

View file

@ -699,6 +699,12 @@ static NSDistributedNotificationCenter *netCenter = nil;
cmd = [NSTask launchPathForTool: @"gdnc"];
if (cmd == nil)
{
[NSException raise: NSInternalInconsistencyException
format: @"Unable to find the gdnc tool.\n"];
}
NSDebugMLLog(@"NSDistributedNotificationCenter",
@"\nI couldn't contact the notification server for %@ -\n"
@"so I'm attempting to to start one - which will take a few seconds.\n"