Server/project/src/ErrorHandler.ts
TheSparta 7aee78eb49 Fixes Insured items on secured containers (!158)
This PR fixes both https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/174 and https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/175.

Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/158
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-23 16:45:40 +00:00

33 lines
1.1 KiB
TypeScript

import readline from "node:readline";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { AsyncQueue } from "@spt-aki/utils/AsyncQueue";
import { UUidGenerator } from "@spt-aki/utils/UUidGenerator";
import { WinstonMainLogger } from "@spt-aki/utils/logging/WinstonMainLogger";
export class ErrorHandler
{
private logger:ILogger;
private readLine: readline.Interface;
constructor()
{
this.logger = new WinstonMainLogger(new AsyncQueue(), new UUidGenerator());
this.readLine = readline.createInterface({
input: process.stdin,
output: process.stdout
});
}
public handleCriticalError(err: any): void
{
this.logger.error("The application had a critical error and failed to run");
this.logger.error(`Exception produced: ${err}`);
if (err.stack)
this.logger.error(`\nStacktrace:\n ${err.stack}`);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
this.readLine.question("Press Enter to close the window", (_ans) => this.readLine.close());
this.readLine.on("close", () => process.exit(0));
}
}