Skip to content

Commit

Permalink
feat(qq): change internal api error to debug (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
idranme authored Jul 22, 2024
1 parent d7c681d commit 5b258de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 1 addition & 2 deletions adapters/qq/src/internal/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ export class Internal {
this.bot.logger.debug(`${method} ${url} response: %o, trace id: %s`, response.data, response.headers.get('x-tps-trace-id'))
return response.data
} catch (error) {
this.bot.logger.warn(`${method} ${url} request: %o`, config)
if (!http.isError(error) || !error.response) throw error
this.bot.logger.warn(`${method} ${url} response: %o, trace id: %s`, error.response.data, error.response.headers.get('x-tps-trace-id'))
this.bot.logger.debug(`${method} ${url} response: %o, trace id: %s`, error.response.data, error.response.headers.get('x-tps-trace-id'))
throw error
}
}
Expand Down
15 changes: 11 additions & 4 deletions adapters/qq/src/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ export class WsClient<C extends Context = Context> extends Adapter.WsClient<C, Q

async prepare() {
if (this.bot.config.authType === 'bearer') await this.bot.getAccessToken()
let { url } = await this.bot.internal.getGateway()
url = url.replace('api.sgroup.qq.com', new URL(this.bot.config.endpoint).host)
this.bot.logger.debug('url: %s', url)
return this.bot.http.ws(url)
try {
let { url } = await this.bot.internal.getGateway()
url = url.replace('api.sgroup.qq.com', new URL(this.bot.config.endpoint).host)
this.bot.logger.debug('url: %s', url)
return this.bot.http.ws(url)
} catch (error) {
if (this.bot.http.isError(error) && error.response) {
this.bot.logger.warn(`GET /gateway response: %o`, error.response.data)
}
throw error
}
}

heartbeat() {
Expand Down

0 comments on commit 5b258de

Please sign in to comment.