mirror of
https://git.bits.team/Bits/mod-manager.git
synced 2024-12-22 04:18:21 -05:00
Make error handling clearer in Mods
This commit is contained in:
parent
fc18d70e49
commit
2b5d2a3643
@ -28,7 +28,9 @@ export default class Mods {
|
||||
if (e instanceof ModNotFoundError) {
|
||||
PrintUtils.info(`Mod not found on ${source.getName()}`);
|
||||
} else {
|
||||
throw e;
|
||||
PrintUtils.error(`An error occurred searching for ${mod} on ${source.getName()}. Skipping ${source.getName()}`, e)
|
||||
// Try the next source
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +41,8 @@ export default class Mods {
|
||||
await source.install(id);
|
||||
PrintUtils.success(`Successfully installed ${mod}`);
|
||||
} catch (e) {
|
||||
PrintUtils.error(`An error occurred while downloading ${mod} from ${source.getName()}`, e);
|
||||
// Log the error, and continue to next source
|
||||
PrintUtils.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,9 +52,22 @@ export default class PrintUtils {
|
||||
console.log(chalk.greenBright(print));
|
||||
}
|
||||
|
||||
static error(print: string, err?: Error) {
|
||||
console.log(chalk.redBright(print));
|
||||
static error(print: string | Error, err?: Error) {
|
||||
// If provided an error
|
||||
if (print instanceof Error) {
|
||||
// Output the error message
|
||||
console.log(chalk.redBright(print.message));
|
||||
|
||||
// If no accompanying error to log was passed, log this one
|
||||
if (err == null) {
|
||||
err = print;
|
||||
}
|
||||
} else {
|
||||
// If a string is provided, output to user
|
||||
console.log(chalk.redBright(print));
|
||||
}
|
||||
|
||||
// If there is an error to log, log it
|
||||
if (err instanceof Error) {
|
||||
if (ModManager.logger != null) {
|
||||
ModManager.logger.error(err)
|
||||
|
Loading…
Reference in New Issue
Block a user