提交 686e13de 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

add(sentry.io): catch exception for analysize. (#580)

上级 38cdcaba
......@@ -72,8 +72,12 @@
"@types/node": {
"version": "7.0.29",
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.29.tgz",
"integrity": "sha512-+8JrLZny/uR+d/jLK9eaV63buRM7X/gNzQk57q76NS4KNKLSKOmxJYFIlwuP2zDvA7wqZj05POPhSd9Z1hYQpQ==",
"dev": true
"integrity": "sha512-+8JrLZny/uR+d/jLK9eaV63buRM7X/gNzQk57q76NS4KNKLSKOmxJYFIlwuP2zDvA7wqZj05POPhSd9Z1hYQpQ=="
},
"@types/raven": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/@types/raven/-/raven-1.2.2.tgz",
"integrity": "sha1-r+Ur2YGHo6PSi4IS42MUO9FvI78="
},
"@types/request": {
"version": "0.0.43",
......@@ -3696,6 +3700,11 @@
"integrity": "sha1-HRdnnAac2l0ECZGgnbwsDbN35V4=",
"dev": true
},
"lsmod": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/lsmod/-/lsmod-1.0.0.tgz",
"integrity": "sha1-mgD3bco26yP6BTUK/htYXUKZ5ks="
},
"make-dir": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.0.0.tgz",
......@@ -5494,6 +5503,23 @@
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
"integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4="
},
"raven": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/raven/-/raven-2.0.2.tgz",
"integrity": "sha1-pD07hwKubbLpGYdii+jyiVAIEK4=",
"dependencies": {
"timed-out": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz",
"integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8="
},
"uuid": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.0.tgz",
"integrity": "sha1-Zyj8BFnEUNeWqZwxg3VpvfZy1yg="
}
}
},
"raw-body": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.2.0.tgz",
......@@ -6109,6 +6135,11 @@
}
}
},
"stack-trace": {
"version": "0.0.9",
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.9.tgz",
"integrity": "sha1-qPbq7KkGdMMz58Q5U/J1tFFRBpU="
},
"stack-utils": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-1.0.1.tgz",
......
......@@ -239,8 +239,26 @@ export interface Sleepable {
*/
process.env['SELENIUM_PROMISE_MANAGER'] = 0
import * as Raven from 'raven'
Raven
.config('https://f6770399ee65459a82af82650231b22c:d8d11b283deb441e807079b8bb2c45cd@sentry.io/179672')
.install()
/*
try {
doSomething(a[0])
} catch (e) {
Raven.captureException(e)
}
Raven.context(function () {
doSomething(a[0])
})
*/
export {
log,
Raven,
}
export default Config
......@@ -18,6 +18,7 @@
*/
import {
Config,
Raven,
Sayable,
log,
} from './config'
......@@ -336,6 +337,7 @@ export class Contact implements Sayable {
return UtilLib.urlStream(avatarUrl, cookies)
} catch (err) {
log.warn('Contact', 'avatar() exception: %s', err.stack)
Raven.captureException(err)
throw err
}
}
......@@ -403,6 +405,7 @@ export class Contact implements Sayable {
} catch (e) {
log.error('Contact', `contactGetter(${this.id}) exception: %s`, e.message)
Raven.captureException(e)
throw e
}
}
......@@ -523,6 +526,7 @@ export class Contact implements Sayable {
.contactFind(filterFunction)
.catch(e => {
log.error('Contact', 'findAll() rejected: %s', e.message)
Raven.captureException(e)
return [] // fail safe
})
await Promise.all(contactList.map(c => c.ready()))
......@@ -639,6 +643,7 @@ export class Contact implements Sayable {
})
.catch(e => {
log.error('Contact', 'alias(%s) rejected: %s', newAlias, e.message)
Raven.captureException(e)
return false // fail safe
})
}
......
......@@ -21,6 +21,7 @@ import * as path from 'path'
import {
Config,
Raven,
RecommendInfo,
Sayable,
log,
......@@ -513,6 +514,7 @@ export class Message implements Sayable {
} catch (e) {
log.error('Message', 'ready() exception: %s', e.stack)
Raven.captureException(e)
// console.log(e)
// this.dump()
// this.dumpRaw()
......@@ -726,6 +728,7 @@ export class MediaMessage extends Message {
} catch (e) {
log.warn('MediaMessage', 'ready() exception: %s', e.message)
Raven.captureException(e)
throw e
}
}
......@@ -805,6 +808,7 @@ export class MediaMessage extends Message {
return UtilLib.urlStream(this.obj.url, cookies)
} catch (e) {
log.warn('MediaMessage', 'stream() exception: %s', e.stack)
Raven.captureException(e)
throw e
}
}
......
......@@ -19,9 +19,10 @@
import {
Config,
HeadName,
log,
Raven,
ScanInfo,
WatchdogFood,
log,
} from '../config'
import Contact from '../contact'
......@@ -121,6 +122,7 @@ export class PuppetWeb extends Puppet {
this.emit('error', e)
await this.quit()
this.state.target('dead')
Raven.captureException(e)
throw e
}
}
......@@ -169,18 +171,21 @@ export class PuppetWeb extends Puppet {
await this.bridge.quit()
.catch(e => { // fail safe
log.warn('PuppetWeb', 'quit() bridge.quit() exception: %s', e.message)
Raven.captureException(e)
})
log.verbose('PuppetWeb', 'quit() bridge.quit() done')
await this.server.quit()
.catch(e => { // fail safe
log.warn('PuppetWeb', 'quit() server.quit() exception: %s', e.message)
Raven.captureException(e)
})
log.verbose('PuppetWeb', 'quit() server.quit() done')
await this.browser.quit()
.catch(e => { // fail safe
log.warn('PuppetWeb', 'quit() browser.quit() exception: %s', e.message)
Raven.captureException(e)
})
log.verbose('PuppetWeb', 'quit() browser.quit() done')
......@@ -194,6 +199,7 @@ export class PuppetWeb extends Puppet {
} catch (e) {
log.error('PuppetWeb', 'quit() exception: %s', e.message)
Raven.captureException(e)
throw e
} finally {
......@@ -222,6 +228,7 @@ export class PuppetWeb extends Puppet {
await this.browser.init()
} catch (e) {
log.error('PuppetWeb', 'initBrowser() exception: %s', e.message)
Raven.captureException(e)
throw e
}
return
......@@ -244,6 +251,7 @@ export class PuppetWeb extends Puppet {
try {
await this.bridge.init()
} catch (e) {
Raven.captureException(e)
if (!this.browser) {
log.warn('PuppetWeb', 'initBridge() without browser?')
} else if (this.browser.dead()) {
......@@ -286,6 +294,7 @@ export class PuppetWeb extends Puppet {
await this.server.init()
.catch(e => {
log.error('PuppetWeb', 'initServer() exception: %s', e.message)
Raven.captureException(e)
throw e
})
return
......@@ -322,6 +331,7 @@ export class PuppetWeb extends Puppet {
return obj.BaseRequest
} catch (e) {
log.error('PuppetWeb', 'send() exception: %s', e.message)
Raven.captureException(e)
throw e
}
}
......@@ -458,6 +468,7 @@ export class PuppetWeb extends Puppet {
ret = await this.bridge.sendMedia(destinationId, mediaId, msgType)
} catch (e) {
log.error('PuppetWeb', 'send() exception: %s', e.message)
Raven.captureException(e)
return false
}
return ret
......@@ -494,6 +505,7 @@ export class PuppetWeb extends Puppet {
ret = await this.bridge.send(destinationId, content)
} catch (e) {
log.error('PuppetWeb', 'send() exception: %s', e.message)
Raven.captureException(e)
throw e
}
}
......@@ -524,6 +536,7 @@ export class PuppetWeb extends Puppet {
await this.bridge.logout()
} catch (e) {
log.error('PuppetWeb', 'logout() exception: %s', e.message)
Raven.captureException(e)
throw e
}
}
......@@ -533,6 +546,7 @@ export class PuppetWeb extends Puppet {
return await this.bridge.getContact(id)
} catch (e) {
log.error('PuppetWeb', 'getContact(%d) exception: %s', id, e.message)
Raven.captureException(e)
throw e
}
}
......@@ -542,6 +556,7 @@ export class PuppetWeb extends Puppet {
return await this.bridge.ding(data)
} catch (e) {
log.warn('PuppetWeb', 'ding(%s) rejected: %s', data, e.message)
Raven.captureException(e)
throw e
}
}
......@@ -558,6 +573,7 @@ export class PuppetWeb extends Puppet {
} catch (e) {
log.warn('PuppetWeb', 'contactRemark(%s, %s) rejected: %s', contact.id, remark, e.message)
Raven.captureException(e)
throw e
}
}
......@@ -570,6 +586,7 @@ export class PuppetWeb extends Puppet {
.then(idList => idList.map(id => Contact.load(id)))
.catch(e => {
log.warn('PuppetWeb', 'contactFind(%s) rejected: %s', filterFunc, e.message)
Raven.captureException(e)
throw e
})
}
......@@ -582,6 +599,7 @@ export class PuppetWeb extends Puppet {
.then(idList => idList.map(id => Room.load(id)))
.catch(e => {
log.warn('PuppetWeb', 'roomFind(%s) rejected: %s', filterFunc, e.message)
Raven.captureException(e)
throw e
})
}
......@@ -595,6 +613,7 @@ export class PuppetWeb extends Puppet {
return this.bridge.roomDelMember(roomId, contactId)
.catch(e => {
log.warn('PuppetWeb', 'roomDelMember(%s, %d) rejected: %s', roomId, contactId, e.message)
Raven.captureException(e)
throw e
})
}
......@@ -608,6 +627,7 @@ export class PuppetWeb extends Puppet {
return this.bridge.roomAddMember(roomId, contactId)
.catch(e => {
log.warn('PuppetWeb', 'roomAddMember(%s) rejected: %s', contact, e.message)
Raven.captureException(e)
throw e
})
}
......@@ -624,6 +644,7 @@ export class PuppetWeb extends Puppet {
return this.bridge.roomModTopic(roomId, topic)
.catch(e => {
log.warn('PuppetWeb', 'roomTopic(%s) rejected: %s', topic, e.message)
Raven.captureException(e)
throw e
})
}
......@@ -648,6 +669,7 @@ export class PuppetWeb extends Puppet {
} catch (e) {
log.warn('PuppetWeb', 'roomCreate(%s, %s) rejected: %s', contactIdList.join(','), topic, e.message)
Raven.captureException(e)
throw e
}
}
......@@ -668,6 +690,7 @@ export class PuppetWeb extends Puppet {
return await this.bridge.verifyUserRequest(contact.id, hello)
} catch (e) {
log.warn('PuppetWeb', 'bridge.verifyUserRequest(%s, %s) rejected: %s', contact.id, hello, e.message)
Raven.captureException(e)
throw e
}
}
......@@ -685,6 +708,7 @@ export class PuppetWeb extends Puppet {
return await this.bridge.verifyUserOk(contact.id, ticket)
} catch (e) {
log.warn('PuppetWeb', 'bridge.verifyUserOk(%s, %s) rejected: %s', contact.id, ticket, e.message)
Raven.captureException(e)
throw e
}
}
......
......@@ -20,6 +20,7 @@ import { EventEmitter } from 'events'
import {
Config,
Raven,
Sayable,
log,
} from './config'
......@@ -155,6 +156,7 @@ export class Room extends EventEmitter implements Sayable {
} catch (e) {
log.error('Room', 'contactGetter(%s) exception: %s', this.id, e.message)
Raven.captureException(e)
throw e
}
}
......@@ -358,6 +360,7 @@ export class Room extends EventEmitter implements Sayable {
log.warn('Room', 'topic(newTopic=%s) exception: %s',
newTopic, e && e.message || e,
)
Raven.captureException(e)
})
if (!this.obj) {
this.obj = <RoomObj>{}
......@@ -548,6 +551,7 @@ export class Room extends EventEmitter implements Sayable {
.roomCreate(contactList, topic)
.catch(e => {
log.error('Room', 'create() exception: %s', e && e.stack || e.message || e)
Raven.captureException(e)
throw e
})
}
......@@ -579,6 +583,7 @@ export class Room extends EventEmitter implements Sayable {
.roomFind(filterFunction)
.catch(e => {
log.verbose('Room', 'findAll() rejected: %s', e.message)
Raven.captureException(e)
return [] // fail safe
})
......
......@@ -26,6 +26,7 @@ import {
Config,
HeadName,
PuppetName,
Raven,
Sayable,
log,
} from './config'
......@@ -194,6 +195,7 @@ export class Wechaty extends EventEmitter implements Sayable {
* 2. git log fail
*/
log.silly('Wechaty', 'version() form development environment is not availble: %s', e.message)
Raven.captureException(e)
}
}
......@@ -248,6 +250,7 @@ export class Wechaty extends EventEmitter implements Sayable {
await this.initPuppet()
} catch (e) {
log.error('Wechaty', 'init() exception: %s', e && e.message)
Raven.captureException(e)
throw e
}
......@@ -408,6 +411,7 @@ export class Wechaty extends EventEmitter implements Sayable {
await puppetBeforeDie.quit()
.catch(e => {
log.error('Wechaty', 'quit() exception: %s', e.message)
Raven.captureException(e)
throw e
})
this.state.current('standby')
......@@ -424,6 +428,7 @@ export class Wechaty extends EventEmitter implements Sayable {
await this.puppet.logout()
.catch(e => {
log.error('Wechaty', 'logout() exception: %s', e.message)
Raven.captureException(e)
throw e
})
return
......@@ -450,6 +455,7 @@ export class Wechaty extends EventEmitter implements Sayable {
return await this.puppet.send(message)
.catch(e => {
log.error('Wechaty', 'send() exception: %s', e.message)
Raven.captureException(e)
throw e
})
}
......@@ -489,6 +495,7 @@ export class Wechaty extends EventEmitter implements Sayable {
return this.puppet.ding() // should return 'dong'
.catch(e => {
log.error('Wechaty', 'ding() exception: %s', e.message)
Raven.captureException(e)
throw e
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册