From 79af725f7f33c70ebf715dd4a16129cf27ab844b Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Tue, 13 Feb 2018 22:28:58 +0000 Subject: [PATCH] Move error event struct --- client/src/modules/contentmanager.js | 4 ++-- client/src/structs/{ => events}/error.js | 10 ++++++---- client/src/structs/events/event.js | 6 ++++-- client/src/structs/events/index.js | 1 + client/src/structs/structs.js | 1 - client/src/ui/components/bd/modals/ErrorModal.vue | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) rename client/src/structs/{ => events}/error.js (81%) diff --git a/client/src/modules/contentmanager.js b/client/src/modules/contentmanager.js index a4835847..d7069696 100644 --- a/client/src/modules/contentmanager.js +++ b/client/src/modules/contentmanager.js @@ -12,7 +12,7 @@ import Globals from './globals'; import { FileUtils, ClientLogger as Logger } from 'common'; import path from 'path'; import { Events } from 'modules'; -import { Error } from 'structs'; +import { ErrorEvent } from 'structs'; import { Modals } from 'ui'; export default class { @@ -38,7 +38,7 @@ export default class { try { await this.preloadContent(dir); } catch (err) { - this.errors.push(new Error({ + this.errors.push(new ErrorEvent({ module: this.moduleName, message: `Failed to load ${dir}`, err diff --git a/client/src/structs/error.js b/client/src/structs/events/error.js similarity index 81% rename from client/src/structs/error.js rename to client/src/structs/events/error.js index df6a8c16..04f8bf8f 100644 --- a/client/src/structs/error.js +++ b/client/src/structs/events/error.js @@ -8,10 +8,12 @@ * LICENSE file in the root directory of this source tree. */ -export class Error { +import Event from './event'; + +export default class ErrorEvent extends Event { constructor(args) { - this.args = args; + super(args); this.showStack = false; // For error modal } @@ -31,8 +33,8 @@ export class Error { return this.err.stack; } - get _type() { - return 'err'; + get __eventType() { + return 'error'; } } diff --git a/client/src/structs/events/event.js b/client/src/structs/events/event.js index 8b33372c..1159910e 100644 --- a/client/src/structs/events/event.js +++ b/client/src/structs/events/event.js @@ -11,8 +11,6 @@ export default class Event { constructor(args) { - this.args = args; - this.__eventInfo = { args: arguments, type: this.__eventType @@ -23,6 +21,10 @@ export default class Event { return this.__eventInfo; } + get args() { + return this.event.args[0]; + } + get __eventType() { return null; } } diff --git a/client/src/structs/events/index.js b/client/src/structs/events/index.js index 287f7741..354e4192 100644 --- a/client/src/structs/events/index.js +++ b/client/src/structs/events/index.js @@ -1 +1,2 @@ export { default as SettingUpdatedEvent } from './settingupdated'; +export { default as ErrorEvent } from './error'; diff --git a/client/src/structs/structs.js b/client/src/structs/structs.js index 4e35157f..4042b56e 100644 --- a/client/src/structs/structs.js +++ b/client/src/structs/structs.js @@ -1,2 +1 @@ -export * from './error'; export * from './events/index'; diff --git a/client/src/ui/components/bd/modals/ErrorModal.vue b/client/src/ui/components/bd/modals/ErrorModal.vue index 8764248b..dec525ea 100644 --- a/client/src/ui/components/bd/modals/ErrorModal.vue +++ b/client/src/ui/components/bd/modals/ErrorModal.vue @@ -4,7 +4,7 @@
-
+
{{content.message}} Hide Stacktrace