mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:24:33 +01:00
std.Io.File.MultiReader: make checkAnyError exclude EndOfStream
This commit is contained in:
parent
8a80b54640
commit
6a1fd3c69d
2 changed files with 8 additions and 8 deletions
|
|
@ -1385,14 +1385,12 @@ fn runCommand(
|
|||
break :term spawnChildAndCollect(run, interp_argv.items, &environ_map, has_side_effects, options, fuzz_context) catch |e| {
|
||||
if (!run.failing_to_execute_foreign_is_an_error) return error.MakeSkipped;
|
||||
if (e == error.MakeFailed) return error.MakeFailed; // error already reported
|
||||
return step.fail("unable to spawn interpreter {s}: {s}", .{
|
||||
interp_argv.items[0], @errorName(e),
|
||||
});
|
||||
return step.fail("unable to spawn interpreter {s}: {t}", .{ interp_argv.items[0], e });
|
||||
};
|
||||
}
|
||||
if (err == error.MakeFailed) return error.MakeFailed; // error already reported
|
||||
|
||||
return step.fail("failed to spawn and capture stdio from {s}: {s}", .{ argv[0], @errorName(err) });
|
||||
return step.fail("failed to spawn and capture stdio from {s}: {t}", .{ argv[0], err });
|
||||
};
|
||||
|
||||
const generic_result = opt_generic_result orelse {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ pub const Context = struct {
|
|||
err: ?Error,
|
||||
};
|
||||
|
||||
pub const Error = Allocator.Error || File.ReadStreamingError || Io.ConcurrentError;
|
||||
pub const Error = UnendingError || error{EndOfStream};
|
||||
pub const UnendingError = Allocator.Error || File.Reader.Error || Io.ConcurrentError;
|
||||
|
||||
/// Trailing:
|
||||
/// * `contexts: [len]Context`
|
||||
|
|
@ -126,13 +127,14 @@ pub fn reader(mr: *MultiReader, index: usize) *Io.Reader {
|
|||
}
|
||||
|
||||
/// Checks for errors in all streams, prioritizing `error.Canceled` if it
|
||||
/// occurred anywhere.
|
||||
pub fn checkAnyError(mr: *const MultiReader) Error!void {
|
||||
/// occurred anywhere, and ignoring `error.EndOfStream`.
|
||||
pub fn checkAnyError(mr: *const MultiReader) UnendingError!void {
|
||||
const contexts = mr.streams.contexts();
|
||||
var other: Error!void = {};
|
||||
var other: UnendingError!void = {};
|
||||
for (contexts) |*context| {
|
||||
if (context.err) |err| switch (err) {
|
||||
error.Canceled => |e| return e,
|
||||
error.EndOfStream => continue,
|
||||
else => |e| other = e,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue