mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
Improve error handling on dependency download (#15661)
verify ok status on response. improve error messages
This commit is contained in:
parent
bc17b38788
commit
87de8212ad
@ -489,8 +489,15 @@ fn fetchAndUnpack(
|
||||
try req.start();
|
||||
try req.wait();
|
||||
|
||||
if (req.response.status != .ok) {
|
||||
return report.fail(dep.url_tok, "Expected response status '200 OK' got '{} {s}'", .{
|
||||
@enumToInt(req.response.status),
|
||||
req.response.status.phrase() orelse "",
|
||||
});
|
||||
}
|
||||
|
||||
const content_type = req.response.headers.getFirstValue("Content-Type") orelse
|
||||
return report.fail(dep.url_tok, "missing Content-Type for '{s}'", .{uri.path});
|
||||
return report.fail(dep.url_tok, "Missing 'Content-Type' header", .{});
|
||||
|
||||
if (ascii.eqlIgnoreCase(content_type, "application/gzip") or
|
||||
ascii.eqlIgnoreCase(content_type, "application/x-gzip") or
|
||||
@ -504,7 +511,7 @@ fn fetchAndUnpack(
|
||||
// by default, so the same logic applies for buffering the reader as for gzip.
|
||||
try unpackTarball(gpa, &req, tmp_directory.handle, std.compress.xz);
|
||||
} else {
|
||||
return report.fail(dep.url_tok, "unknown file extension for path '{s}'", .{uri.path});
|
||||
return report.fail(dep.url_tok, "Unsupported 'Content-Type' header value: '{s}'", .{content_type});
|
||||
}
|
||||
|
||||
// TODO: delete files not included in the package prior to computing the package hash.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user