diff options
| author | DraagrenKirneh <h_n91@hotmail.com> | 2023-05-13 23:41:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-13 17:41:11 -0400 |
| commit | 87de8212adac280780900f8a68c302c6bc127c47 (patch) | |
| tree | 1a51b7bac906247352ff62aa3ada78146e8fc7c1 /src | |
| parent | bc17b38788e173afefc6a4770e5b0610dbe44670 (diff) | |
| download | zig-87de8212adac280780900f8a68c302c6bc127c47.tar.gz zig-87de8212adac280780900f8a68c302c6bc127c47.zip | |
Improve error handling on dependency download (#15661)
verify ok status on response. improve error messages
Diffstat (limited to 'src')
| -rw-r--r-- | src/Package.zig | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Package.zig b/src/Package.zig index db29fde77a..f4593fee48 100644 --- a/src/Package.zig +++ b/src/Package.zig @@ -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. |
