| 12345678910111213141516171819202122232425 | 
							- 'use strict';
 
- /**
 
-  * 异常处理
 
-  *
 
-  * @author CaiAoLin
 
-  * @date 2017/10/25
 
-  * @version
 
-  */
 
- module.exports = () => {
 
-     return function* errorHandler(next) {
 
-         try {
 
-             yield next;
 
-         } catch (err) {
 
-             // 注意:自定义的错误统一处理函数捕捉到错误后也要 `app.emit('error', err, this)`
 
-             // 框架会统一监听,并打印对应的错误日志
 
-             this.app.emit('error', err, this);
 
-             // mysql重连
 
-             if (err.code === 'PROTOCOL_CONNECTION_LOST') {
 
-                 this.app.mysql.createInstance(this.app.config.mysql.client);
 
-             }
 
-         }
 
-     };
 
- };
 
 
  |