diff --git a/src/application/base/baseEvent.ts b/src/application/base/baseEvent.ts index bb623c3..a7297d2 100644 --- a/src/application/base/baseEvent.ts +++ b/src/application/base/baseEvent.ts @@ -25,12 +25,13 @@ export abstract class BaseEvent { protected emitError(message: string): void { this.socket.emit('notification', { title: 'Server message', message }) - this.logger.error('character:connect error', `Player ${this.socket.userId}: ${message}`) + this.logger.error('Base event error', `Player ${this.socket.userId}: ${message}`) } protected handleError(context: string, error: unknown): void { - const errorMessage = error instanceof Error ? error.message : String(error) - this.emitError(`${context}: ${errorMessage}`) - this.logger.error('character:connect error', errorMessage) + console.log(error) + const errorMessage = error instanceof Error ? error.message : error && typeof error === 'object' && 'toString' in error ? error.toString() : String(error) + this.socket.emit('notification', { title: 'Server message', message: `Server error occured. Please contact the server administrator.` }) + this.logger.error('Base event error', errorMessage) } }