From 300e5411f6e9c9eb16c008f01329f66921573188 Mon Sep 17 00:00:00 2001 From: Huan LI Date: Mon, 28 Nov 2016 17:39:46 +0800 Subject: [PATCH] more log & code clean --- README.md | 7 +++++++ example/speech-to-text-bot.ts | 2 +- src/puppet-web/event.ts | 10 +++++----- test/puppet-web/puppet-web.spec.ts | 2 ++ test/puppet-web/watchdog.spec.ts | 6 ++++++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 508f9eba..9b6501e5 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,13 @@ You can directly submit pull requests for documentation changes. * [RelatedProject](https://github.com/wechaty/wechaty/wiki/RelatedProject) +# Todo + +* [ ] Use Dependency Injection for FriendRequest(etc) + - https://github.com/young-steveo/bottlejs + - http://jonnyreeves.co.uk/2015/basic-typescript-dependency-injection-with-decorators/ + - https://github.com/connorwyatt/Fluency-Injection + My Story ---------------- My daily life/work depends on too much chat on wechat. diff --git a/example/speech-to-text-bot.ts b/example/speech-to-text-bot.ts index c7e4efc2..6582f234 100644 --- a/example/speech-to-text-bot.ts +++ b/example/speech-to-text-bot.ts @@ -148,7 +148,7 @@ async function wavToText(readableStream: NodeJS.ReadableStream): Promise try { const obj = JSON.parse(body) if (obj.err_no !== 0) { - return reject(new Error(obj.err_msg)) + throw new Error(obj.err_msg) } return resolve(obj.result[0]) diff --git a/src/puppet-web/event.ts b/src/puppet-web/event.ts index a3a22f3b..818a624c 100644 --- a/src/puppet-web/event.ts +++ b/src/puppet-web/event.ts @@ -121,11 +121,11 @@ async function onBrowserDead(this: PuppetWeb, e: Error): Promise { log.verbose('PuppetWebEvent', 'onBrowserDead() new browser borned') - // why POISON here... forgot, faint - this.emit('watchdog', { - data: `onBrowserDead() new browser borned` - , type: 'POISON' - }) + // why POISON here... forgot, faint. comment it out to treat dog nicer... 20161128 + // this.emit('watchdog', { + // data: `onBrowserDead() new browser borned` + // , type: 'POISON' + // }) return } diff --git a/test/puppet-web/puppet-web.spec.ts b/test/puppet-web/puppet-web.spec.ts index 4abdfacc..4228e234 100644 --- a/test/puppet-web/puppet-web.spec.ts +++ b/test/puppet-web/puppet-web.spec.ts @@ -18,7 +18,9 @@ import { Server } from '../../src/puppet-web/server' // import { spy } from 'sinon' process.on('unhandledRejection', (reason, p) => { + console.log('!!!!!!!') console.log('Unhandled Rejection at: Promise', p, 'reason:', reason) + console.log('!!!!!!!') }) /** diff --git a/test/puppet-web/watchdog.spec.ts b/test/puppet-web/watchdog.spec.ts index 8a94e441..56aa3caa 100644 --- a/test/puppet-web/watchdog.spec.ts +++ b/test/puppet-web/watchdog.spec.ts @@ -20,6 +20,12 @@ import { const PROFILE = 'unit-test-session.wechaty.json' +process.on('unhandledRejection', (reason, p) => { + console.log('!!!!!!!') + console.log('Unhandled Rejection at: Promise', p, 'reason:', reason) + console.log('!!!!!!!') +}) + test('timer', async t => { const pw = new PuppetWeb({profile: PROFILE}) t.truthy(pw, 'should instantiate a PuppetWeb') -- GitLab