mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	refactor(backend_log): improve handle 'file not found'
handle errors more "user friendly" and actually let the user know, that either the file is not existing (yet), or that reading the log failed.
This commit is contained in:
		
							parent
							
								
									67d858441a
								
							
						
					
					
						commit
						dcfdb67539
					
				| @ -14,10 +14,16 @@ async function getBackendLog() { | |||||||
|         const file = join(LOG_DIR, fileName); |         const file = join(LOG_DIR, fileName); | ||||||
|         return await readFile(file, "utf8"); |         return await readFile(file, "utf8"); | ||||||
|     } catch (e) { |     } catch (e) { | ||||||
|         log.error((e instanceof Error) ? e : `Reading the backend log '${fileName}' failed with an unknown error.`); |         const isErrorInstance = e instanceof Error; | ||||||
| 
 | 
 | ||||||
|         // most probably the log file does not exist yet - https://github.com/zadam/trilium/issues/1977
 |         // most probably the log file does not exist yet - https://github.com/zadam/trilium/issues/1977
 | ||||||
|         return ""; |         if (isErrorInstance && "code" in e && e.code === "ENOENT") { | ||||||
|  |             log.error(e); | ||||||
|  |             return `The backend log file '${fileName}' does not exist (yet).`; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         log.error(isErrorInstance ? e : `Reading the backend log '${fileName}' failed with an unknown error: '${e}'.`); | ||||||
|  |         return `Reading the backend log '${fileName}' failed.`; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Panagiotis Papadopoulos
						Panagiotis Papadopoulos