authorgravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-29 04:05:46 -08:00
committergravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-29 04:05:46 -08:00
log346ad7b89a2eb1fce88ea59caa0209e266ef40b0
treeb014ca9db5b759f8582cc1400d5462001ac780cb
parent8e4624ad4051d31d793822cff9a03aad2a675abf

clarify zig.mod init filenotfound error message


1 files changed, 7 insertions(+), 1 deletions(-)

src/util/modfile.zig+7-1
......@@ -23,7 +23,13 @@ pub const ModFile = struct {
2323
2424 pub fn init(alloc: *std.mem.Allocator, fpath: []const u8) !Self {
2525 //
26 const mpath = try std.fs.realpathAlloc(alloc, fpath);
26 const mpath = try std.fs.realpathAlloc(alloc, fpath) catch |e| switch (e) {
27 error.FileNotFound => {
28 u.assert(false, "zig.mod file not found in the current directory, run 'zigmod init' to get started.", .{});
29 unreachable;
30 },
31 else => e,
32 };
2733 const file = try std.fs.openFileAbsolute(mpath, .{});
2834 defer file.close();
2935 const input = try file.reader().readAllAlloc(alloc, mb);