diff options
| author | Benjamin Feng <benjamin.feng@glassdoor.com> | 2019-07-31 21:28:25 -0500 |
|---|---|---|
| committer | Benjamin Feng <benjamin.feng@glassdoor.com> | 2019-07-31 21:28:25 -0500 |
| commit | 327abdba0b5de1f1eeef32e19b6a16ec4c7ec323 (patch) | |
| tree | ce85a4a789043ef5d889d4034d4fc1392239fa2b | |
| parent | e40513e97ff57960165b30a6b9fecfaad95bd1aa (diff) | |
| download | zig-327abdba0b5de1f1eeef32e19b6a16ec4c7ec323.tar.gz zig-327abdba0b5de1f1eeef32e19b6a16ec4c7ec323.zip | |
More current style for error handling
| -rw-r--r-- | std/build.zig | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/std/build.zig b/std/build.zig index acd3a1e33b..997e2ab901 100644 --- a/std/build.zig +++ b/std/build.zig @@ -805,11 +805,7 @@ pub const Builder = struct { return name; } const full_path = try fs.path.join(self.allocator, [_][]const u8{ search_prefix, "bin", self.fmt("{}{}", name, exe_extension) }); - if (fs.realpathAlloc(self.allocator, full_path)) |real_path| { - return real_path; - } else |_| { - continue; - } + return fs.realpathAlloc(self.allocator, full_path) catch continue; } } if (self.env_map.get("PATH")) |PATH| { @@ -820,11 +816,7 @@ pub const Builder = struct { var it = mem.tokenize(PATH, [_]u8{fs.path.delimiter}); while (it.next()) |path| { const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) }); - if (fs.realpathAlloc(self.allocator, full_path)) |real_path| { - return real_path; - } else |_| { - continue; - } + return fs.realpathAlloc(self.allocator, full_path) catch continue; } } } @@ -834,11 +826,7 @@ pub const Builder = struct { } for (paths) |path| { const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) }); - if (fs.realpathAlloc(self.allocator, full_path)) |real_path| { - return real_path; - } else |_| { - continue; - } + return fs.realpathAlloc(self.allocator, full_path) catch continue; } } return error.FileNotFound; |
