| ... | @@ -23,7 +23,13 @@ pub const ModFile = struct { | ... | @@ -23,7 +23,13 @@ pub const ModFile = struct { |
| 23 | | 23 | |
| 24 | pub fn init(alloc: *std.mem.Allocator, fpath: []const u8) !Self { | 24 | pub fn init(alloc: *std.mem.Allocator, fpath: []const u8) !Self { |
| 25 | // | 25 | // |
| 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 | }; |
| 27 | const file = try std.fs.openFileAbsolute(mpath, .{}); | 33 | const file = try std.fs.openFileAbsolute(mpath, .{}); |
| 28 | defer file.close(); | 34 | defer file.close(); |
| 29 | const input = try file.reader().readAllAlloc(alloc, mb); | 35 | const input = try file.reader().readAllAlloc(alloc, mb); |