add error struct

This commit is contained in:
Jiiks 2018-02-07 16:41:10 +02:00
parent bcdd694ec9
commit bf0c74b516
4 changed files with 35 additions and 3 deletions

View File

@ -12,6 +12,7 @@ import Globals from './globals';
import { FileUtils, ClientLogger as Logger } from 'common'; import { FileUtils, ClientLogger as Logger } from 'common';
import path from 'path'; import path from 'path';
import { Events } from 'modules'; import { Events } from 'modules';
import { Error } from 'structs';
export default class { export default class {
@ -33,11 +34,11 @@ export default class {
await this.preloadContent(dir); await this.preloadContent(dir);
} catch (err) { } catch (err) {
//We don't want every plugin/theme to fail loading when one does //We don't want every plugin/theme to fail loading when one does
Events.emit('bd-error', { /*Events.emit('bd-error', {
header: `${this.moduleName} - Failed to load plugin: ${dir}`, header: `${this.moduleName} - Failed to load plugin: ${dir}`,
text: err.message, text: err.message,
type: 'err' type: 'err'
}); });*/
Logger.err(this.moduleName, err); Logger.err(this.moduleName, err);
} }
} }

View File

@ -0,0 +1,29 @@
/**
* BetterDiscord Error Struct
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
* All rights reserved.
* https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export class Error {
constructor(args) {
this.args = args;
}
get module() {
return this.args.module;
}
get message() {
return this.args.message;
}
get err() {
return this.args.err;
}
}

View File

@ -0,0 +1 @@
export * from './error';

View File

@ -45,7 +45,8 @@ module.exports = {
path.resolve('..', 'common', 'modules'), path.resolve('..', 'common', 'modules'),
path.resolve('src', 'modules'), path.resolve('src', 'modules'),
path.resolve('src', 'ui'), path.resolve('src', 'ui'),
path.resolve('src', 'plugins') path.resolve('src', 'plugins'),
path.resolve('src', 'structs')
] ]
} }
/* resolve: { /* resolve: {