Skip to content

Commit 976ea61

Browse files
Peter MarreckPeter Marreck
authored andcommitted
fix: friendly error message when embedding server is unreachable
Instead of a raw Zig stack trace with ConnectionRefused, now prints: "error: Cannot connect to embedding server at <url>" with a hint to start Ollama.
1 parent 4a7945b commit 976ea61

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/main.zig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,18 @@ fn ensureModelAvailableOrExit(
14841484
_ = stderr.flush() catch {};
14851485
// Continue — embed() will block until model is loaded
14861486
},
1487-
else => return err,
1487+
else => {
1488+
var stderr_buf: [4096]u8 = undefined;
1489+
var stderr_writer = std.fs.File.stderr().writer(&stderr_buf);
1490+
const stderr = &stderr_writer.interface;
1491+
_ = stderr.print(
1492+
"error: Cannot connect to embedding server at {s}\n" ++
1493+
" Is Ollama running? Start it with: ollama serve\n",
1494+
.{ base_url },
1495+
) catch {};
1496+
_ = stderr.flush() catch {};
1497+
std.process.exit(1);
1498+
},
14881499
};
14891500
}
14901501

0 commit comments

Comments
 (0)