fix(core): onError doesn't register
This commit is contained in:
parent
cf97a88b0e
commit
dc99a9103b
1 changed files with 9 additions and 1 deletions
|
@ -238,7 +238,7 @@ export class MtClient extends EventEmitter {
|
||||||
|
|
||||||
readonly _config = new ConfigManager(() => this.call({ _: 'help.getConfig' }))
|
readonly _config = new ConfigManager(() => this.call({ _: 'help.getConfig' }))
|
||||||
|
|
||||||
emitError: (err: unknown, connection?: SessionConnection) => void = console.error.bind(console)
|
private _emitError?: (err: unknown, connection?: SessionConnection) => void
|
||||||
|
|
||||||
readonly log: Logger
|
readonly log: Logger
|
||||||
readonly network: NetworkManager
|
readonly network: NetworkManager
|
||||||
|
@ -310,6 +310,14 @@ export class MtClient extends EventEmitter {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emitError(err: unknown, connection?: SessionConnection): void {
|
||||||
|
if (this._emitError) {
|
||||||
|
this._emitError(err, connection)
|
||||||
|
} else {
|
||||||
|
this.log.error('unhandled error:', err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _prepare = asyncResettable(async () => {
|
private _prepare = asyncResettable(async () => {
|
||||||
await this.crypto.initialize?.()
|
await this.crypto.initialize?.()
|
||||||
await this.storage.load()
|
await this.storage.load()
|
||||||
|
|
Loading…
Reference in a new issue