aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-12-14 00:42:31 +0200
committerGitHub <noreply@github.com>2022-12-14 00:42:31 +0200
commit65270cdc3345e9840427179168a09ef6e4dd34b9 (patch)
tree3d4cd45795caaae02817d6642b1a373b07150b55 /src/Compilation.zig
parent9be5323e93123a3979037997fa40a95b4c985b85 (diff)
parent7561f63b5d93fb32b39410590625bb16bf2ac0dd (diff)
downloadzig-65270cdc3345e9840427179168a09ef6e4dd34b9.tar.gz
zig-65270cdc3345e9840427179168a09ef6e4dd34b9.zip
Merge pull request #12298 from r00ster91/debugerror
std.debug: handle some possible errors and resolve low-hanging TODOs
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 06d978ecae..911089df02 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -428,29 +428,29 @@ pub const AllErrors = struct {
switch (msg) {
.src => |src| {
try counting_stderr.writeByteNTimes(' ', indent);
- ttyconf.setColor(stderr, .Bold);
+ try ttyconf.setColor(stderr, .Bold);
try counting_stderr.print("{s}:{d}:{d}: ", .{
src.src_path,
src.line + 1,
src.column + 1,
});
- ttyconf.setColor(stderr, color);
+ try ttyconf.setColor(stderr, color);
try counting_stderr.writeAll(kind);
try counting_stderr.writeAll(": ");
// This is the length of the part before the error message:
// e.g. "file.zig:4:5: error: "
const prefix_len = @intCast(usize, counting_stderr.context.bytes_written);
- ttyconf.setColor(stderr, .Reset);
- ttyconf.setColor(stderr, .Bold);
+ try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .Bold);
if (src.count == 1) {
try src.writeMsg(stderr, prefix_len);
try stderr.writeByte('\n');
} else {
try src.writeMsg(stderr, prefix_len);
- ttyconf.setColor(stderr, .Dim);
+ try ttyconf.setColor(stderr, .Dim);
try stderr.print(" ({d} times)\n", .{src.count});
}
- ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .Reset);
if (src.source_line) |line| {
for (line) |b| switch (b) {
'\t' => try stderr.writeByte(' '),
@@ -462,19 +462,19 @@ pub const AllErrors = struct {
// -1 since span.main includes the caret
const after_caret = src.span.end - src.span.main -| 1;
try stderr.writeByteNTimes(' ', src.column - before_caret);
- ttyconf.setColor(stderr, .Green);
+ try ttyconf.setColor(stderr, .Green);
try stderr.writeByteNTimes('~', before_caret);
try stderr.writeByte('^');
try stderr.writeByteNTimes('~', after_caret);
try stderr.writeByte('\n');
- ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .Reset);
}
for (src.notes) |note| {
try note.renderToWriter(ttyconf, stderr, "note", .Cyan, indent);
}
if (src.reference_trace.len != 0) {
- ttyconf.setColor(stderr, .Reset);
- ttyconf.setColor(stderr, .Dim);
+ try ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .Dim);
try stderr.print("referenced by:\n", .{});
for (src.reference_trace) |reference| {
switch (reference) {
@@ -498,23 +498,23 @@ pub const AllErrors = struct {
}
}
try stderr.writeByte('\n');
- ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .Reset);
}
},
.plain => |plain| {
- ttyconf.setColor(stderr, color);
+ try ttyconf.setColor(stderr, color);
try stderr.writeByteNTimes(' ', indent);
try stderr.writeAll(kind);
try stderr.writeAll(": ");
- ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .Reset);
if (plain.count == 1) {
try stderr.print("{s}\n", .{plain.msg});
} else {
try stderr.print("{s}", .{plain.msg});
- ttyconf.setColor(stderr, .Dim);
+ try ttyconf.setColor(stderr, .Dim);
try stderr.print(" ({d} times)\n", .{plain.count});
}
- ttyconf.setColor(stderr, .Reset);
+ try ttyconf.setColor(stderr, .Reset);
for (plain.notes) |note| {
try note.renderToWriter(ttyconf, stderr, "note", .Cyan, indent + 4);
}