From 346ad7b89a2eb1fce88ea59caa0209e266ef40b0 Mon Sep 17 00:00:00 2001 From: Meghan Date: Sun, 29 Nov 2020 04:05:46 -0800 Subject: [PATCH] clarify zig.mod init filenotfound error message --- src/util/modfile.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/modfile.zig b/src/util/modfile.zig index 62ab2cbc45154cfab8085dba230c1dc89d27c2a6..be643430612a52e7350816c34bd87cb54530a8e7 100644 --- a/src/util/modfile.zig +++ b/src/util/modfile.zig @@ -23,7 +23,13 @@ pub const ModFile = struct { pub fn init(alloc: *std.mem.Allocator, fpath: []const u8) !Self { // - const mpath = try std.fs.realpathAlloc(alloc, fpath); + const mpath = try std.fs.realpathAlloc(alloc, fpath) catch |e| switch (e) { + error.FileNotFound => { + u.assert(false, "zig.mod file not found in the current directory, run 'zigmod init' to get started.", .{}); + unreachable; + }, + else => e, + }; const file = try std.fs.openFileAbsolute(mpath, .{}); defer file.close(); const input = try file.reader().readAllAlloc(alloc, mb); -- 2.54.0