Authored by yyq

异常处理

@@ -43,7 +43,7 @@ exports.index = (req, res) => { @@ -43,7 +43,7 @@ exports.index = (req, res) => {
43 * @param {[type]} res [description] 43 * @param {[type]} res [description]
44 * @return {[type]} [description] 44 * @return {[type]} [description]
45 */ 45 */
46 -exports.channel = (req, res) => { 46 +exports.channel = (req, res, next) => {
47 let resData = { 47 let resData = {
48 module: 'product', 48 module: 'product',
49 page: 'outlets' 49 page: 'outlets'
@@ -51,11 +51,7 @@ exports.channel = (req, res) => { @@ -51,11 +51,7 @@ exports.channel = (req, res) => {
51 51
52 outlets.getOutletsChannelData(req.query, req.params.channel).then(result => { 52 outlets.getOutletsChannelData(req.query, req.params.channel).then(result => {
53 res.render('outlets/channel', Object.assign(resData, result)); 53 res.render('outlets/channel', Object.assign(resData, result));
54 - }).catch((e) => {  
55 - log.error(e);  
56 - resData.pageErr = true;  
57 - res.render('error', resData);  
58 - }); 54 + }).catch(next);
59 }; 55 };
60 56
61 /** 57 /**
@@ -64,7 +60,7 @@ exports.channel = (req, res) => { @@ -64,7 +60,7 @@ exports.channel = (req, res) => {
64 * @param {[type]} res [description] 60 * @param {[type]} res [description]
65 * @return {[type]} [description] 61 * @return {[type]} [description]
66 */ 62 */
67 -exports.special = (req, res) => { 63 +exports.special = (req, res, next) => {
68 let params = req.query; 64 let params = req.query;
69 let channel = req.query.channel || req.cookies._Channel || 'boys'; 65 let channel = req.query.channel || req.cookies._Channel || 'boys';
70 let resData = { 66 let resData = {
@@ -78,11 +74,7 @@ exports.special = (req, res) => { @@ -78,11 +74,7 @@ exports.special = (req, res) => {
78 74
79 outlets.getOutletsSpecialData(params, channel).then(result => { 75 outlets.getOutletsSpecialData(params, channel).then(result => {
80 res.render('outlets/special', Object.assign(resData, result)); 76 res.render('outlets/special', Object.assign(resData, result));
81 - }).catch((e) => {  
82 - log.error(e);  
83 - resData.pageErr = true;  
84 - res.render('error', resData);  
85 - }); 77 + }).catch(next);
86 }; 78 };
87 79
88 /** 80 /**
@@ -91,7 +83,7 @@ exports.special = (req, res) => { @@ -91,7 +83,7 @@ exports.special = (req, res) => {
91 * @param {[type]} res [description] 83 * @param {[type]} res [description]
92 * @return {[type]} [description] 84 * @return {[type]} [description]
93 */ 85 */
94 -exports.list = (req, res) => { 86 +exports.list = (req, res, next) => {
95 let params = req.query; 87 let params = req.query;
96 88
97 let channel = req.query.channel || req.cookies._Channel || 'boys'; 89 let channel = req.query.channel || req.cookies._Channel || 'boys';
@@ -104,12 +96,7 @@ exports.list = (req, res) => { @@ -104,12 +96,7 @@ exports.list = (req, res) => {
104 }; 96 };
105 97
106 outlets.getOutletsCategoryData(params, channel).then((result) => { 98 outlets.getOutletsCategoryData(params, channel).then((result) => {
107 - responseData.resultShow = JSON.stringify(result, null, 4);  
108 res.render('sale/other', Object.assign(responseData, result)); 99 res.render('sale/other', Object.assign(responseData, result));
109 - }).catch((e) => {  
110 - log.error(e);  
111 - responseData.pageErr = true;  
112 - res.render('error', responseData);  
113 - }); 100 + }).catch(next);
114 101
115 }; 102 };