Skip to content

Commit

Permalink
more log & code clean
Browse files Browse the repository at this point in the history
  • Loading branch information
huan committed Nov 28, 2016
1 parent 9c825a7 commit 300e541
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion example/speech-to-text-bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async function wavToText(readableStream: NodeJS.ReadableStream): Promise<string>
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])
Expand Down
10 changes: 5 additions & 5 deletions src/puppet-web/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ async function onBrowserDead(this: PuppetWeb, e: Error): Promise<void> {

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
}
Expand Down
2 changes: 2 additions & 0 deletions test/puppet-web/puppet-web.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('!!!!!!!')
})

/**
Expand Down
6 changes: 6 additions & 0 deletions test/puppet-web/watchdog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 300e541

Please sign in to comment.