diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-11-25 17:42:27 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-11-25 17:43:27 -0700 |
| commit | 7b78b4fff02e5f59da3034ee739c0eae99a01de5 (patch) | |
| tree | 22d29adc7469faae3c7c119aad0acc1e0b136657 /src | |
| parent | 2006add8496c47804ee3b6c562f420871cb4ea0a (diff) | |
| download | zig-7b78b4fff02e5f59da3034ee739c0eae99a01de5.tar.gz zig-7b78b4fff02e5f59da3034ee739c0eae99a01de5.zip | |
stage2: better error message when copying artifacts fails
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compilation.zig | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 9da855789f..64e08c62be 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1885,7 +1885,7 @@ pub fn update(self: *Compilation) !void { // Flush takes care of -femit-bin, but we still have -femit-llvm-ir, -femit-llvm-bc, and // -femit-asm to handle, in the case of C objects. - try self.emitOthers(); + self.emitOthers(); // If there are any errors, we anticipate the source files being loaded // to report error messages. Otherwise we unload all source files to save memory. @@ -1902,7 +1902,7 @@ pub fn update(self: *Compilation) !void { } } -fn emitOthers(comp: *Compilation) !void { +fn emitOthers(comp: *Compilation) void { if (comp.bin_file.options.output_mode != .Obj or comp.bin_file.options.module != null or comp.c_object_table.count() == 0) { @@ -1925,9 +1925,16 @@ fn emitOthers(comp: *Compilation) !void { for (outs) |out| { if (out.emit) |loc| { if (loc.directory) |directory| { - const src_path = try std.fmt.allocPrint(comp.gpa, "{s}{s}", .{ basename, out.ext }); + const src_path = std.fmt.allocPrint(comp.gpa, "{s}{s}", .{ + basename, out.ext, + }) catch |err| { + log.err("unable to copy {s}{s}: {s}", .{ basename, out.ext, @errorName(err) }); + continue; + }; defer comp.gpa.free(src_path); - try cwd.copyFile(src_path, directory.handle, loc.basename, .{}); + cwd.copyFile(src_path, directory.handle, loc.basename, .{}) catch |err| { + log.err("unable to copy {s}: {s}", .{ src_path, @errorName(err) }); + }; } } } |
