From 088d007816425bf8cba0dc55e6bb2168d4692130 Mon Sep 17 00:00:00 2001 From: Thoronium <107363768+NotThorny@users.noreply.github.com> Date: Sun, 26 Feb 2023 03:02:52 -0700 Subject: [PATCH] Revert handle and add logging Server.ts isn't actually printing the error to the user anyways so there was no point in trying to fix it --- src-tauri/src/file_helpers.rs | 10 +++++++++- src/utils/server.ts | 6 ------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src-tauri/src/file_helpers.rs b/src-tauri/src/file_helpers.rs index d33a0af..1b591b3 100644 --- a/src-tauri/src/file_helpers.rs +++ b/src-tauri/src/file_helpers.rs @@ -130,7 +130,15 @@ pub fn read_file(path: String) -> String { let mut file = match fs::File::open(path_buf) { Ok(file) => file, - Err(e) => return String.from::(""); // Send back error for handling by the caller + Err(e) => { + if path.contains("config") { + // Server.ts won't print the error so handle the message here for the user + println!("Server config not found or invalid. Be sure to run the server at least once to generate it before making edits."); + } else { + println!("Failed to open file: {}", e); + } + return String::new(); // Send back error for handling by the caller + } }; let mut contents = String::new(); diff --git a/src/utils/server.ts b/src/utils/server.ts index 4b5b425..e1e572c 100644 --- a/src/utils/server.ts +++ b/src/utils/server.ts @@ -40,11 +40,5 @@ export async function encryptionEnabled(path: string) { return false } - // Also check if null just in case - if (serverConf == null) { - console.log(`Server config at ${path} not found or invalid. Be sure to run the server at least once to generate it`) - return false - } - return serverConf.server.http.encryption.useEncryption }