diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-12-11 13:58:11 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-01-02 16:57:15 -0700 |
| commit | ebcfc86bb9c8cec1a66511858a6443b1927191f2 (patch) | |
| tree | 2be53c4b601960fcc716313774baf212064a31ab /src/Compilation.zig | |
| parent | c1f404ad537ded5a584525f7f89dcf5705a2c405 (diff) | |
| download | zig-ebcfc86bb9c8cec1a66511858a6443b1927191f2.tar.gz zig-ebcfc86bb9c8cec1a66511858a6443b1927191f2.zip | |
Compilation: better error message for file not found
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index a18b05a939..4c7489c0c8 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -584,7 +584,17 @@ pub const AllErrors = struct { Message.HashContext, std.hash_map.default_max_load_percentage, ).init(allocator); - const err_source = try module_err_msg.src_loc.file_scope.getSource(module.gpa); + const err_source = module_err_msg.src_loc.file_scope.getSource(module.gpa) catch |err| { + const file_path = try module_err_msg.src_loc.file_scope.fullPath(allocator); + try errors.append(.{ + .plain = .{ + .msg = try std.fmt.allocPrint(allocator, "unable to load '{s}': {s}", .{ + file_path, @errorName(err), + }), + }, + }); + return; + }; const err_span = try module_err_msg.src_loc.span(module.gpa); const err_loc = std.zig.findLineColumn(err_source.bytes, err_span.main); |
