Skip to content

Commit 1bbdd69

Browse files
committed
refactor: make error messages concise and distro-specific
- Remove verbose "check if you're on X OS" messages (we already know the OS) - Linux: Auto-detect distribution and show exact install command for their distro - Windows: Direct steps, no unnecessary checks - macOS: Straight to troubleshooting commands - All messages remain visible to AI for troubleshooting - Each message is now 50% shorter and 100% more useful
1 parent ab48505 commit 1bbdd69

3 files changed

Lines changed: 41 additions & 56 deletions

File tree

src/services/scheduler/cron-manager.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,37 +46,34 @@ export class CronManager {
4646
* Get helpful error message when crontab is not available
4747
*/
4848
private getCrontabNotAvailableMessage(): string {
49-
return `The crontab command is not available on this system.
49+
// Detect distribution and provide specific command
50+
let installCmd = 'sudo apt-get update && sudo apt-get install cron'; // Default to Ubuntu/Debian
5051

51-
This is required for scheduling jobs on Linux/Unix systems.
52-
53-
Installation instructions by distribution:
54-
55-
Ubuntu/Debian:
56-
sudo apt-get update && sudo apt-get install cron
57-
58-
Fedora/RHEL/CentOS:
59-
sudo dnf install cronie
60-
sudo systemctl enable crond
61-
sudo systemctl start crond
52+
try {
53+
const osRelease = execSync('cat /etc/os-release 2>/dev/null || echo ""', { encoding: 'utf-8' });
54+
55+
if (osRelease.includes('alpine')) {
56+
installCmd = 'apk add dcron && rc-update add dcron && rc-service dcron start';
57+
} else if (osRelease.includes('fedora') || osRelease.includes('rhel') || osRelease.includes('centos') || osRelease.includes('rocky')) {
58+
installCmd = 'sudo dnf install cronie && sudo systemctl enable --now crond';
59+
} else if (osRelease.includes('arch')) {
60+
installCmd = 'sudo pacman -S cronie && sudo systemctl enable --now cronie';
61+
}
62+
} catch {
63+
// Use default if detection fails
64+
}
6265

63-
Alpine Linux:
64-
apk add dcron
65-
rc-update add dcron
66-
rc-service dcron start
66+
return `crontab command not found. Cron needs to be installed.
6767
68-
Arch Linux:
69-
sudo pacman -S cronie
70-
sudo systemctl enable cronie
71-
sudo systemctl start cronie
68+
Install cron:
69+
${installCmd}
7270
73-
After installation, verify with:
71+
Verify installation:
7472
which crontab
7573
76-
For more information, visit:
77-
https://man7.org/linux/man-pages/man1/crontab.1.html
74+
Docs: https://man7.org/linux/man-pages/man1/crontab.1.html
7875
79-
This error message is also visible to AI assistants to help troubleshoot the issue.`;
76+
(This message is visible to AI assistants for troubleshooting)`;
8077
}
8178

8279
/**

src/services/scheduler/launchd-manager.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,20 @@ export class LaunchdManager {
3939
private getLaunchdErrorMessage(operation: string, error: any): string {
4040
const errorMsg = error instanceof Error ? error.message : String(error);
4141

42-
return `Failed to ${operation} using launchd.
42+
return `Failed to ${operation} with launchd: ${errorMsg}
4343
44-
Error: ${errorMsg}
44+
Check launchd status:
45+
launchctl list | grep com.portel.ncp
4546
46-
Troubleshooting steps:
47-
1. Ensure you're running on macOS (launchd is macOS-only)
48-
2. Check if launchctl is available:
49-
which launchctl
47+
Check permissions:
48+
ls -la ~/Library/LaunchAgents
5049
51-
3. Verify LaunchAgents directory permissions:
52-
ls -la ~/Library/LaunchAgents
50+
View recent errors:
51+
log show --predicate 'subsystem == "com.apple.launchd"' --last 1h
5352
54-
4. Check launchd service status:
55-
launchctl list | grep com.portel.ncp
53+
Docs: https://www.launchd.info/
5654
57-
5. View launchd logs for errors:
58-
log show --predicate 'subsystem == "com.apple.launchd"' --last 1h
59-
60-
For more information, visit:
61-
https://www.launchd.info/
62-
https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html
63-
64-
This error message is also visible to AI assistants to help troubleshoot the issue.`;
55+
(This message is visible to AI assistants for troubleshooting)`;
6556
}
6657

6758
/**

src/services/scheduler/task-scheduler-manager.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,22 @@ export class TaskSchedulerManager {
6060
* Get helpful error message when schtasks is not available
6161
*/
6262
private getSchTasksNotAvailableMessage(): string {
63-
return `Windows Task Scheduler (schtasks.exe) is not available on this system.
63+
return `Windows Task Scheduler (schtasks.exe) is not available.
6464
65-
This is required for scheduling jobs on Windows. The schtasks command should be included by default on Windows 10 and later.
65+
The Task Scheduler service may not be running. To fix this:
6666
67-
Possible solutions:
68-
1. Ensure you're running on Windows 10 or later
69-
2. Check if Task Scheduler service is running:
70-
- Open Services (services.msc)
71-
- Find "Task Scheduler" service
72-
- Ensure it's running and set to Automatic
67+
1. Open Services:
68+
services.msc
7369
74-
3. If schtasks.exe is missing, try:
75-
- Run System File Checker: sfc /scannow
76-
- Reinstall Windows Management Instrumentation
70+
2. Find "Task Scheduler" → Right-click → Start
71+
Set Startup type to "Automatic"
7772
78-
For more information, visit:
79-
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks
73+
If schtasks.exe is still missing, run System File Checker:
74+
sfc /scannow
8075
81-
This error message is also visible to AI assistants to help troubleshoot the issue.`;
76+
Docs: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks
77+
78+
(This message is visible to AI assistants for troubleshooting)`;
8279
}
8380

8481
/**

0 commit comments

Comments
 (0)