authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-10-19 00:09:52-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-10-23 16:27:38-07:00
log3cc19cd86518f8ae2a7bd48577d30577cfbbd391
treee862825f98356ab4262b1e5aed49816ae876bdce
parentd1ecb742ec5cb80e29178fddefe6663bed40daa8

better error messages


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

src/link.zig+6-6
......@@ -1383,12 +1383,12 @@ pub const File = struct {
13831383 for (comp.link_inputs) |input| {
13841384 base.loadInput(input) catch |err| switch (err) {
13851385 error.LinkFailure => return, // error reported via link_diags
1386 else => |e| {
1387 if (input.path()) |path| {
1388 comp.link_diags.addParseError(path, "failed to parse linker input: {s}", .{@errorName(e)});
1389 } else {
1390 comp.link_diags.addError("failed to {s}: {s}", .{ input.taskName(), @errorName(e) });
1391 }
1386 else => |e| switch (input) {
1387 .dso => |dso| comp.link_diags.addParseError(dso.path, "failed to parse shared library: {s}", .{@errorName(e)}),
1388 .object => |obj| comp.link_diags.addParseError(obj.path, "failed to parse object: {s}", .{@errorName(e)}),
1389 .archive => |obj| comp.link_diags.addParseError(obj.path, "failed to parse archive: {s}", .{@errorName(e)}),
1390 .res => |res| comp.link_diags.addParseError(res.path, "failed to parse Windows resource: {s}", .{@errorName(e)}),
1391 .dso_exact => comp.link_diags.addError("failed to handle dso_exact: {s}", .{@errorName(e)}),
13921392 },
13931393 };
13941394 }
test/link/elf.zig+1-1
......@@ -3910,7 +3910,7 @@ fn testUnknownFileTypeError(b: *Build, opts: Options) *Step {
39103910 exe.linkLibC();
39113911
39123912 expectLinkErrors(exe, test_step, .{
3913 .contains = "error: failed to parse shared object: BadMagic",
3913 .contains = "error: failed to parse shared library: BadMagic",
39143914 });
39153915
39163916 return test_step;