authorgravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-29 02:41:09 -08:00
committergravatar for hello@nektro.netMeghan <hello@nektro.net> 2020-11-29 02:41:09 -08:00
logcbbc164603e46629ab1808663f1d751b0d715e9d
tree31b950e503e7df68b02c5ff7131eb5d72e6f35d0
parent337d392073fa5613f8f7be01bb096c97a86c39d7

print an error message on failed assertions


2 files changed, 3 insertions(+), 3 deletions(-)

src/cmd_init.zig+2-2
...@@ -29,7 +29,7 @@ fn detect_pkgname(def: []const u8) ![]const u8 {...@@ -29,7 +29,7 @@ fn detect_pkgname(def: []const u8) ![]const u8 {
29 const split = try u.split(dpath, "/");29 const split = try u.split(dpath, "/");
30 var name = split[split.len-1];30 var name = split[split.len-1];
31 name = u.trim_prefix(name, "zig-");31 name = u.trim_prefix(name, "zig-");
32 std.debug.assert(name.len > 0);32 u.assert(name.len > 0, "package name must not be an empty string", .{});
33 return name;33 return name;
34}34}
3535
...@@ -41,6 +41,6 @@ fn detct_mainfile(def: []const u8) ![]const u8 {...@@ -41,6 +41,6 @@ fn detct_mainfile(def: []const u8) ![]const u8 {
41 }41 }
42 }42 }
43 }43 }
44 std.debug.assert(try u.does_file_exist("./src/main.zig"));
45 return "src/main.zig";44 return "src/main.zig";
45 u.assert(false, "unable to detect package entry point", .{});
46}46}
src/util/yaml.zig+1-1
...@@ -104,7 +104,7 @@ pub fn parse(alloc: *std.mem.Allocator, input: []const u8) !Document {...@@ -104,7 +104,7 @@ pub fn parse(alloc: *std.mem.Allocator, input: []const u8) !Document {
104 l = all_events.items.len;104 l = all_events.items.len;
105 }105 }
106106
107 std.debug.assert(all_events.items.len == 1);107 u.assert(all_events.items.len == 1, "failure parsing zig.mod. please report an issue at https://github.com/nektro/zigmod/issues/new that contains the text of your zig.mod.");
108 return all_events.items[0].document;108 return all_events.items[0].document;
109}109}
110110