From 8fb7379d7111f8d7f931cec7e03573949137e930 Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Mon, 17 Oct 2022 20:46:31 +0200 Subject: [PATCH] return null if file can't be read in documentstore --- src/DocumentStore.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/DocumentStore.zig b/src/DocumentStore.zig index 7e5a309..e2e85a9 100644 --- a/src/DocumentStore.zig +++ b/src/DocumentStore.zig @@ -682,13 +682,13 @@ fn createDocumentFromURI(self: *DocumentStore, uri: Uri, open: bool) error{OutOf const tracy_zone = tracy.trace(@src()); defer tracy_zone.end(); - const file_path = URI.parse(self.allocator, uri) catch unreachable; + const file_path = URI.parse(self.allocator, uri) catch return null; defer self.allocator.free(file_path); - var file = std.fs.openFileAbsolute(file_path, .{}) catch unreachable; + var file = std.fs.openFileAbsolute(file_path, .{}) catch return null; defer file.close(); - const file_contents = file.readToEndAllocOptions(self.allocator, std.math.maxInt(usize), null, @alignOf(u8), 0) catch unreachable; + const file_contents = file.readToEndAllocOptions(self.allocator, std.math.maxInt(usize), null, @alignOf(u8), 0) catch return null; return try self.createDocument(uri, file_contents, open); }