mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 08:57:02 +02:00
feat(server): improve error logging using banner
This commit is contained in:
@@ -6,7 +6,7 @@ export default class ServerPlatformProvider implements PlatformProvider {
|
||||
readonly isWindows = process.platform === "win32";
|
||||
|
||||
crash(message: string): void {
|
||||
getLog().error(message);
|
||||
getLog().banner(message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getMessagingProvider, utils } from "@triliumnext/core";
|
||||
import { getMessagingProvider, getPlatform, utils } from "@triliumnext/core";
|
||||
import type { Express } from "express";
|
||||
import fs from "fs";
|
||||
import http from "http";
|
||||
@@ -155,20 +155,13 @@ function startHttpServer(app: Express) {
|
||||
}
|
||||
|
||||
if (utils.isElectron()) {
|
||||
import("electron").then(({ app, dialog }) => {
|
||||
// Not all situations require showing an error dialog. When Trilium is already open,
|
||||
// clicking the shortcut, the software icon, or the taskbar icon, or when creating a new window,
|
||||
// should simply focus on the existing window or open a new one, without displaying an error message.
|
||||
if ("code" in error && error.code === "EADDRINUSE" && (process.argv.includes("--new-window") || !app.requestSingleInstanceLock())) {
|
||||
console.error(message);
|
||||
} else {
|
||||
dialog.showErrorBox("Error while initializing the server", message);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
if ("code" in error && error.code === "EADDRINUSE" && (process.argv.includes("--new-window") || !app.requestSingleInstanceLock())) {
|
||||
console.error(message);
|
||||
} else {
|
||||
getPlatform().crash(`Error while initializing the server: ${message}`);
|
||||
}
|
||||
} else {
|
||||
console.error(message);
|
||||
process.exit(1);
|
||||
getPlatform().crash(message);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user