Skip to content

Commit

Permalink
优化错误信息
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Jul 14, 2022
1 parent d09b6f1 commit 188fb00
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {connect, Socket} from 'net'
import pTimeout from 'p-timeout'
import {Duplex} from 'stream'
import {Container} from 'typedi'
import {VError} from 'verror'
import {Backend} from './backend'
import {Config} from './config'
import {IPacket} from './constants'
Expand Down Expand Up @@ -77,7 +78,6 @@ export class Client extends EventEmitter {
}

public async awaitHandshake(): Promise<number> {
if (this.host) return
this.state = states.HANDSHAKING
for await (const chunk of this.splitter) {
const packet: IPacket = this.deserializer.parsePacketBuffer(chunk)
Expand Down Expand Up @@ -108,7 +108,9 @@ export class Client extends EventEmitter {
this.logger.fields['username'] = this.username
return 2
default:
throw new Error(`unexpected packet ${name}`)
throw new VError({
info: packet,
}, `unexpected packet ${name}`)
}
}
}
Expand Down

0 comments on commit 188fb00

Please sign in to comment.