mirror of
https://git.bits.team/Bits/mod-manager.git
synced 2024-11-14 10:28:21 -05:00
Added an error parameter to PrintUtils#error to allow logging of an accompany Error obj
This commit is contained in:
parent
6b700d465b
commit
fc18d70e49
@ -47,7 +47,7 @@ export default class ModManager {
|
|||||||
static createLogger(): Logger {
|
static createLogger(): Logger {
|
||||||
let logger = pino({base: {pid: undefined, hostname: undefined}}, pino.destination({dest: this.LOG_FILE}));
|
let logger = pino({base: {pid: undefined, hostname: undefined}}, pino.destination({dest: this.LOG_FILE}));
|
||||||
process.on("uncaughtException", error => {
|
process.on("uncaughtException", error => {
|
||||||
logger.error(error);
|
PrintUtils.error(error.message, error);
|
||||||
setTimeout(() => process.exit(1), 1)
|
setTimeout(() => process.exit(1), 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ export default class Mods {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof ModNotFoundError) {
|
if (e instanceof ModNotFoundError) {
|
||||||
PrintUtils.info(`Mod not found on ${source.getName()}`);
|
PrintUtils.info(`Mod not found on ${source.getName()}`);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +39,7 @@ export default class Mods {
|
|||||||
await source.install(id);
|
await source.install(id);
|
||||||
PrintUtils.success(`Successfully installed ${mod}`);
|
PrintUtils.success(`Successfully installed ${mod}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
PrintUtils.error(`An error occurred downloading ${mod} from ${source.getName()}`);
|
PrintUtils.error(`An error occurred while downloading ${mod} from ${source.getName()}`, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import ora, {Ora} from "ora";
|
import ora, {Ora} from "ora";
|
||||||
|
import ModManager from "../mod-manager.js";
|
||||||
|
|
||||||
export default class PrintUtils {
|
export default class PrintUtils {
|
||||||
|
|
||||||
@ -51,7 +52,13 @@ export default class PrintUtils {
|
|||||||
console.log(chalk.greenBright(print));
|
console.log(chalk.greenBright(print));
|
||||||
}
|
}
|
||||||
|
|
||||||
static error(print: string) {
|
static error(print: string, err?: Error) {
|
||||||
console.log(chalk.redBright(print));
|
console.log(chalk.redBright(print));
|
||||||
|
|
||||||
|
if (err instanceof Error) {
|
||||||
|
if (ModManager.logger != null) {
|
||||||
|
ModManager.logger.error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user