@@ -99,13 +99,22 @@ - (void)startWithConfigDir:(NSString *)configDir port:(int)port
9999 if (_task != nil ) return ;
100100
101101 if (![self hasBinary ]) {
102- [self setError: @" Server binary not found" ];
102+ [self setError: @" Server binary not found in application bundle. "
103+ @" Please reinstall Lemoniscate." ];
103104 return ;
104105 }
105106
106107 /* Validate port */
107108 if (port < 1 || port > 65535 ) {
108- [self setError: @" Port must be between 1 and 65535" ];
109+ [self setError: @" Port must be between 1 and 65535. The default is 5500." ];
110+ return ;
111+ }
112+
113+ /* Check config directory exists */
114+ BOOL isDir = NO ;
115+ if (![[NSFileManager defaultManager ] fileExistsAtPath: configDir isDirectory: &isDir] || !isDir) {
116+ [self setError: [NSString stringWithFormat:
117+ @" Configuration directory not found: %@ " , configDir]];
109118 return ;
110119 }
111120
@@ -276,8 +285,27 @@ - (void)taskDidTerminate:(NSNotification *)note
276285 if (exitStatus == 0 || exitStatus == SIGTERM || exitStatus == SIGINT) {
277286 [self setStatus: ServerStatusStopped];
278287 } else {
279- [self setError: [NSString stringWithFormat:
280- @" Server exited with code %d " , exitStatus]];
288+ NSString *detail;
289+ switch (exitStatus) {
290+ case 1 :
291+ detail = @" Server failed to start. Check that the port is not "
292+ @" already in use and the configuration is valid." ;
293+ break ;
294+ case 11 : /* SIGSEGV */
295+ detail = @" Server crashed (segmentation fault). "
296+ @" Please report this issue." ;
297+ break ;
298+ case 6 : /* SIGABRT */
299+ detail = @" Server aborted unexpectedly. "
300+ @" Check the log for details." ;
301+ break ;
302+ default :
303+ detail = [NSString stringWithFormat:
304+ @" Server exited unexpectedly (code %d ). "
305+ @" Check the log tab for details." , exitStatus];
306+ break ;
307+ }
308+ [self setError: detail];
281309 }
282310}
283311
0 commit comments